@@ -114,19 +114,19 @@ export const NeoTableChart = (props: ChartProps) => {
114114 const actionableFields = actionsRules . map ( ( r ) => r . field ) ;
115115
116116 const columns = transposed
117- ? [ 'Field' ] . concat ( records . map ( ( r , j ) => `Value ${ j == 0 ? '' : ` ${ ( j + 1 ) . toString ( ) } ` } ` ) ) . map ( ( key , i ) => {
118- const value = key ;
117+ ? [ records [ 0 ] . keys [ 0 ] ] . concat ( records . map ( ( record ) => record . _fields [ 0 ] ? .toString ( ) || '' ) ) . map ( ( key , i ) => {
118+ const uniqueKey = ` ${ String ( key ) } _ ${ i } ` ;
119119 return ApplyColumnType (
120120 {
121121 key : `col-key-${ i } ` ,
122- field : generateSafeColumnKey ( key ) ,
122+ field : generateSafeColumnKey ( uniqueKey ) ,
123123 headerName : generateSafeColumnKey ( key ) ,
124124 headerClassName : 'table-small-header' ,
125125 disableColumnSelector : true ,
126126 flex : columnWidths && i < columnWidths . length ? columnWidths [ i ] : 1 ,
127127 disableClickEventBubbling : true ,
128128 } ,
129- value ,
129+ key ,
130130 actionableFields . includes ( key )
131131 ) ;
132132 } )
@@ -166,15 +166,32 @@ export const NeoTableChart = (props: ChartProps) => {
166166 ...columns . filter ( ( x ) => x . field . startsWith ( HIDDEN_COLUMN_PREFIX ) ) . map ( ( x ) => ( { [ x . field ] : false } ) )
167167 ) ;
168168
169+ const getTransposedRows = ( records ) => {
170+ // Skip first key
171+ const rowKeys = [ ...records [ 0 ] . keys ] ;
172+ rowKeys . shift ( ) ;
173+
174+ // Add values in rows
175+ const rowsWithValues = rowKeys . map ( ( key , i ) =>
176+ Object . assign (
177+ { id : i , Field : key } ,
178+ ...records . map ( ( record , j ) => ( {
179+ [ `${ record . _fields [ 0 ] } _${ j + 1 } ` ] : RenderSubValue ( record . _fields [ i + 1 ] ) ,
180+ } ) )
181+ )
182+ ) ;
183+
184+ // Add field in rows
185+ const rowsWithFieldAndValues = rowsWithValues . map ( ( row , i ) => ( {
186+ ...row ,
187+ [ `${ records [ 0 ] . keys [ 0 ] } _${ 0 } ` ] : rowKeys [ i ] ,
188+ } ) ) ;
189+
190+ return rowsWithFieldAndValues ;
191+ } ;
192+
169193 const rows = transposed
170- ? records [ 0 ] . keys . map ( ( key , i ) => {
171- return Object . assign (
172- { id : i , Field : key } ,
173- ...records . map ( ( r , j ) => ( {
174- [ `Value${ j == 0 ? '' : ` ${ ( j + 1 ) . toString ( ) } ` } ` ] : RenderSubValue ( r . _fields [ i ] ) ,
175- } ) )
176- ) ;
177- } )
194+ ? getTransposedRows ( records )
178195 : records . map ( ( record , rownumber ) => {
179196 return Object . assign (
180197 { id : rownumber } ,
0 commit comments