@@ -60,7 +60,7 @@ export const normalizeFilters = (filters: {
6060 . filter ( ( k ) => filters [ key ] [ k ] !== undefined )
6161 . forEach ( ( k ) => {
6262 filter . push ( {
63- column : key ,
63+ column : key . replaceAll ( '%%%' , '.' ) ,
6464 filterBy : k as FilterOptionsEnum ,
6565 value : filters [ key ] [ k ]
6666 } ) ;
@@ -199,6 +199,16 @@ export const updateTable = async (
199199 sendModel . filter = normalizeFilters ( filters ) ;
200200 sendModel . order = order ;
201201
202+ // remove %%% from the columns object
203+ if ( sendModel . order ) {
204+ sendModel . order . forEach ( ( order ) => {
205+ if ( order . column . includes ( "%%%" ) ) {
206+ const newKey = order . column . replaceAll ( '%%%' , '.' ) ;
207+ order . column = newKey ;
208+ }
209+ } ) ;
210+ }
211+
202212 let fetchData ;
203213
204214 try {
@@ -221,28 +231,43 @@ export const updateTable = async (
221231
222232 // Format server columns to the client columns
223233 if ( response . columns !== undefined ) {
234+ console . log ( 'Server columns' , response . columns ) ;
224235 columns = convertServerColumns ( response . columns , columns ) ;
225236
226237 const clientCols = response . columns . reduce ( ( acc , col ) => {
227- acc [ col . key ] = col . column ;
238+ console . log ( col . key , col . column ) ;
239+ // replace the . with empty string
240+ //const key = col.key.replaceAll('.' ,'');
241+ ///console.log(key, col.column);
242+ // set the key to the columns object
243+ col . column = col . column . replaceAll ( '.' , "%%%" ) ;
244+ col . key = col . key . replaceAll ( '.' , "%%%" ) ;
245+ acc [ col . key ] = col . column
246+ //acc[col.column] = col.column;
247+
228248 return acc ;
229249 } , { } ) ;
230250
231251 const tmpArr : any [ ] = [ ] ;
232-
252+ // tmp[clientCols["['" + key.replaceAll('.', ",") +"']"]] = row[key];
233253 response . data . forEach ( ( row , index ) => {
234254 const tmp : { [ key : string ] : any } = { } ;
235255 Object . keys ( row ) . forEach ( ( key ) => {
236- tmp [ clientCols [ key ] ] = row [ key ] ;
256+ tmp [ clientCols [ key . replaceAll ( '.' , "%%%" ) ] ] = row [ key ]
237257 } ) ;
238258 tmpArr . push ( tmp ) ;
239259 } ) ;
240260 dispatch ( 'fetch' , columns ) ;
241261 data . set ( tmpArr ) ;
262+ console . log ( 'Server data' , tmpArr ) ;
263+ return data ;
242264 }
243265
244266 serverItems ?. set ( response . count ) ;
245267 console . log ( 'Server data updated' ) ;
268+
269+
270+ // log the columns object
246271 console . log ( response ) ;
247272 return response ;
248273} ;
@@ -291,17 +316,17 @@ export const convertServerColumns = (
291316 }
292317
293318 if ( columns && col . column in columns ) {
294- columnsConfig [ col . column ] = {
295- ...columns [ col . column ] ,
319+ columnsConfig [ col . column . replaceAll ( '.' , "%%%" ) ] = {
320+ ...columns [ col . column . replaceAll ( '.' , "%%%" ) ] ,
296321 instructions
297322 } ;
298323 } else {
299- columnsConfig [ col . column ] = {
324+ columnsConfig [ col . column . replaceAll ( '.' , "%%%" ) ] = {
300325 instructions
301326 } ;
302327 }
303328 } ) ;
304-
329+ console . log ( 'Columns config' , columnsConfig ) ;
305330 return columnsConfig ;
306331} ;
307332// Calculates the maximum height of the cells in each row
0 commit comments