@@ -46,6 +46,7 @@ import {
4646 RecordNode ,
4747 RecordNodeToValue ,
4848 routeByNameAction ,
49+ ValueAndMsg ,
4950 withFunction ,
5051 wrapChildAction ,
5152} from "lowcoder-core" ;
@@ -55,7 +56,7 @@ import { lastValueIfEqual, shallowEqual } from "util/objectUtils";
5556import { IContainer } from "../containerBase" ;
5657import { getSelectedRowKeys } from "./selectionControl" ;
5758import { compTablePropertyView } from "./tablePropertyView" ;
58- import { RowColorComp , RowHeightComp , TableChildrenView , TableInitComp } from "./tableTypes" ;
59+ import { RowColorComp , RowHeightComp , SortValue , TableChildrenView , TableInitComp } from "./tableTypes" ;
5960
6061import { useContext , useState } from "react" ;
6162import { EditorContext } from "comps/editorState" ;
@@ -295,19 +296,37 @@ export class TableImplComp extends TableInitComp implements IContainer {
295296
296297 // handle sort: data -> sortedData
297298 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+ } = {
299306 data : this . children . data . exposingNode ( ) ,
300307 sort : this . children . sort . node ( ) ,
301308 dataIndexes : this . children . columns . getColumnsNode ( "dataIndex" ) ,
302309 sortables : this . children . columns . getColumnsNode ( "sortable" ) ,
310+ withParams : this . children . columns . withParamsNode ( ) ,
303311 } ;
304312 const sortedDataNode = withFunction ( fromRecord ( nodes ) , ( input ) => {
305313 const { data, sort, dataIndexes, sortables } = input ;
306- const columns = _ ( dataIndexes )
314+ const sortColumns = _ ( dataIndexes )
307315 . mapValues ( ( dataIndex , idx ) => ( { sortable : ! ! sortables [ idx ] } ) )
308316 . mapKeys ( ( sortable , idx ) => dataIndexes [ idx ] )
309317 . 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 ) ;
311330 // console.info( "sortNode. data: ", data, " sort: ", sort, " columns: ", columns, " sortedData: ", sortedData);
312331 return sortedData ;
313332 } ) ;
0 commit comments