@@ -163,17 +163,28 @@ export const ObjectGrid: React.FC<ObjectGridProps> = ({
163163 const cols = normalizeColumns ( schema . columns ) ;
164164
165165 if ( cols ) {
166- // If columns are already ListColumn objects, convert them to data-table format
166+ // Check if columns are already in data-table format (have 'accessorKey')
167+ // vs ListColumn format (have 'field')
167168 if ( cols . length > 0 && typeof cols [ 0 ] === 'object' && cols [ 0 ] !== null ) {
168- return ( cols as ListColumn [ ] )
169- . filter ( ( col ) => col ?. field && typeof col . field === 'string' ) // Filter out invalid column objects
170- . map ( ( col ) => ( {
171- header : col . label || col . field . charAt ( 0 ) . toUpperCase ( ) + col . field . slice ( 1 ) . replace ( / _ / g, ' ' ) ,
172- accessorKey : col . field ,
173- ...( col . width && { width : col . width } ) ,
174- ...( col . align && { align : col . align } ) ,
175- sortable : col . sortable !== false ,
176- } ) ) ;
169+ const firstCol = cols [ 0 ] as any ;
170+
171+ // Already in data-table format - use as-is
172+ if ( 'accessorKey' in firstCol ) {
173+ return cols ;
174+ }
175+
176+ // ListColumn format - convert to data-table format
177+ if ( 'field' in firstCol ) {
178+ return ( cols as ListColumn [ ] )
179+ . filter ( ( col ) => col ?. field && typeof col . field === 'string' ) // Filter out invalid column objects
180+ . map ( ( col ) => ( {
181+ header : col . label || col . field . charAt ( 0 ) . toUpperCase ( ) + col . field . slice ( 1 ) . replace ( / _ / g, ' ' ) ,
182+ accessorKey : col . field ,
183+ ...( col . width && { width : col . width } ) ,
184+ ...( col . align && { align : col . align } ) ,
185+ sortable : col . sortable !== false ,
186+ } ) ) ;
187+ }
177188 }
178189
179190 // String array format - filter out invalid entries
0 commit comments