@@ -60,7 +60,7 @@ export const normalizeFilters = (filters: {
60
60
. filter ( ( k ) => filters [ key ] [ k ] !== undefined )
61
61
. forEach ( ( k ) => {
62
62
filter . push ( {
63
- column : key ,
63
+ column : key . replaceAll ( '%%%' , '.' ) ,
64
64
filterBy : k as FilterOptionsEnum ,
65
65
value : filters [ key ] [ k ]
66
66
} ) ;
@@ -199,6 +199,16 @@ export const updateTable = async (
199
199
sendModel . filter = normalizeFilters ( filters ) ;
200
200
sendModel . order = order ;
201
201
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
+
202
212
let fetchData ;
203
213
204
214
try {
@@ -221,28 +231,43 @@ export const updateTable = async (
221
231
222
232
// Format server columns to the client columns
223
233
if ( response . columns !== undefined ) {
234
+ console . log ( 'Server columns' , response . columns ) ;
224
235
columns = convertServerColumns ( response . columns , columns ) ;
225
236
226
237
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
+
228
248
return acc ;
229
249
} , { } ) ;
230
250
231
251
const tmpArr : any [ ] = [ ] ;
232
-
252
+ // tmp[clientCols["['" + key.replaceAll('.', ",") +"']"]] = row[key];
233
253
response . data . forEach ( ( row , index ) => {
234
254
const tmp : { [ key : string ] : any } = { } ;
235
255
Object . keys ( row ) . forEach ( ( key ) => {
236
- tmp [ clientCols [ key ] ] = row [ key ] ;
256
+ tmp [ clientCols [ key . replaceAll ( '.' , "%%%" ) ] ] = row [ key ]
237
257
} ) ;
238
258
tmpArr . push ( tmp ) ;
239
259
} ) ;
240
260
dispatch ( 'fetch' , columns ) ;
241
261
data . set ( tmpArr ) ;
262
+ console . log ( 'Server data' , tmpArr ) ;
263
+ return data ;
242
264
}
243
265
244
266
serverItems ?. set ( response . count ) ;
245
267
console . log ( 'Server data updated' ) ;
268
+
269
+
270
+ // log the columns object
246
271
console . log ( response ) ;
247
272
return response ;
248
273
} ;
@@ -291,17 +316,17 @@ export const convertServerColumns = (
291
316
}
292
317
293
318
if ( columns && col . column in columns ) {
294
- columnsConfig [ col . column ] = {
295
- ...columns [ col . column ] ,
319
+ columnsConfig [ col . column . replaceAll ( '.' , "%%%" ) ] = {
320
+ ...columns [ col . column . replaceAll ( '.' , "%%%" ) ] ,
296
321
instructions
297
322
} ;
298
323
} else {
299
- columnsConfig [ col . column ] = {
324
+ columnsConfig [ col . column . replaceAll ( '.' , "%%%" ) ] = {
300
325
instructions
301
326
} ;
302
327
}
303
328
} ) ;
304
-
329
+ console . log ( 'Columns config' , columnsConfig ) ;
305
330
return columnsConfig ;
306
331
} ;
307
332
// Calculates the maximum height of the cells in each row
0 commit comments