88 GridReadyEvent ,
99 IGetRowsParams ,
1010 ModuleRegistry ,
11+ SortModelItem ,
1112} from "ag-grid-community" ;
1213import { v4 } from "uuid" ;
1314
@@ -34,12 +35,16 @@ const clearQueryTimeout = (): void => {
3435 clearTimeout ( queryTableDataTimeoutId ) ;
3536 queryTableDataTimeoutId = null ;
3637} ;
37- const queryTableData = ( start : number , end : number ) : Promise < TableData > => {
38+ const queryTableData = (
39+ start : number ,
40+ end : number ,
41+ sortModel : SortModelItem [ ] ,
42+ ) : Promise < TableData > => {
3843 const requestKey = v4 ( ) ;
3944 vscode . postMessage ( {
4045 command : "request:loadData" ,
4146 key : requestKey ,
42- data : { start, end } ,
47+ data : { start, end, sortModel } ,
4348 } ) ;
4449
4550 return new Promise ( ( resolve , reject ) => {
@@ -103,23 +108,25 @@ const useDataViewer = () => {
103108 const dataSource = {
104109 rowCount : undefined ,
105110 getRows : async ( params : IGetRowsParams ) => {
106- await queryTableData ( params . startRow , params . endRow ) . then (
107- ( { rows, count } : TableData ) => {
108- const rowData = rows . map ( ( { cells } ) => {
109- const row = cells . reduce (
110- ( carry , cell , index ) => ( {
111- ...carry ,
112- [ columns [ index ] . field ] : cell ,
113- } ) ,
114- { } ,
115- ) ;
116-
117- return row ;
118- } ) ;
119-
120- params . successCallback ( rowData , count ) ;
121- } ,
122- ) ;
111+ await queryTableData (
112+ params . startRow ,
113+ params . endRow ,
114+ params . sortModel ,
115+ ) . then ( ( { rows, count } : TableData ) => {
116+ const rowData = rows . map ( ( { cells } ) => {
117+ const row = cells . reduce (
118+ ( carry , cell , index ) => ( {
119+ ...carry ,
120+ [ columns [ index ] . field ] : cell ,
121+ } ) ,
122+ { } ,
123+ ) ;
124+
125+ return row ;
126+ } ) ;
127+
128+ params . successCallback ( rowData , count ) ;
129+ } ) ;
123130 } ,
124131 } ;
125132
0 commit comments