@@ -46,6 +46,7 @@ import {
46
46
RecordNode ,
47
47
RecordNodeToValue ,
48
48
routeByNameAction ,
49
+ ValueAndMsg ,
49
50
withFunction ,
50
51
wrapChildAction ,
51
52
} from "lowcoder-core" ;
@@ -55,7 +56,7 @@ import { lastValueIfEqual, shallowEqual } from "util/objectUtils";
55
56
import { IContainer } from "../containerBase" ;
56
57
import { getSelectedRowKeys } from "./selectionControl" ;
57
58
import { compTablePropertyView } from "./tablePropertyView" ;
58
- import { RowColorComp , RowHeightComp , TableChildrenView , TableInitComp } from "./tableTypes" ;
59
+ import { RowColorComp , RowHeightComp , SortValue , TableChildrenView , TableInitComp } from "./tableTypes" ;
59
60
60
61
import { useContext , useState } from "react" ;
61
62
import { EditorContext } from "comps/editorState" ;
@@ -295,19 +296,37 @@ export class TableImplComp extends TableInitComp implements IContainer {
295
296
296
297
// handle sort: data -> sortedData
297
298
sortDataNode ( ) {
298
- const nodes = {
299
+ const nodes : {
300
+ data : Node < JSONObject [ ] > ;
301
+ sort : Node < SortValue [ ] > ;
302
+ dataIndexes : RecordNode < Record < string , Node < string > > > ;
303
+ sortables : RecordNode < Record < string , Node < ValueAndMsg < boolean > > > > ;
304
+ withParams : RecordNode < _ . Dictionary < any > > ,
305
+ } = {
299
306
data : this . children . data . exposingNode ( ) ,
300
307
sort : this . children . sort . node ( ) ,
301
308
dataIndexes : this . children . columns . getColumnsNode ( "dataIndex" ) ,
302
309
sortables : this . children . columns . getColumnsNode ( "sortable" ) ,
310
+ withParams : this . children . columns . withParamsNode ( ) ,
303
311
} ;
304
312
const sortedDataNode = withFunction ( fromRecord ( nodes ) , ( input ) => {
305
313
const { data, sort, dataIndexes, sortables } = input ;
306
- const columns = _ ( dataIndexes )
314
+ const sortColumns = _ ( dataIndexes )
307
315
. mapValues ( ( dataIndex , idx ) => ( { sortable : ! ! sortables [ idx ] } ) )
308
316
. mapKeys ( ( sortable , idx ) => dataIndexes [ idx ] )
309
317
. value ( ) ;
310
- const sortedData = sortData ( data , columns , sort ) ;
318
+ const dataColumns = _ ( dataIndexes )
319
+ . mapValues ( ( dataIndex , idx ) => ( {
320
+ dataIndex,
321
+ render : input . withParams [ idx ] as any ,
322
+ } ) )
323
+ . value ( ) ;
324
+ const updatedData : Array < RecordType > = data . map ( ( row , index ) => ( {
325
+ ...row ,
326
+ [ OB_ROW_ORI_INDEX ] : index + "" ,
327
+ } ) ) ;
328
+ const originalData = getOriDisplayData ( updatedData , 1000 , Object . values ( dataColumns ) )
329
+ const sortedData = sortData ( originalData , sortColumns , sort ) ;
311
330
// console.info( "sortNode. data: ", data, " sort: ", sort, " columns: ", columns, " sortedData: ", sortedData);
312
331
return sortedData ;
313
332
} ) ;
0 commit comments