8
8
GridReadyEvent ,
9
9
IGetRowsParams ,
10
10
ModuleRegistry ,
11
+ SortModelItem ,
11
12
} from "ag-grid-community" ;
12
13
import { v4 } from "uuid" ;
13
14
@@ -34,12 +35,16 @@ const clearQueryTimeout = (): void => {
34
35
clearTimeout ( queryTableDataTimeoutId ) ;
35
36
queryTableDataTimeoutId = null ;
36
37
} ;
37
- const queryTableData = ( start : number , end : number ) : Promise < TableData > => {
38
+ const queryTableData = (
39
+ start : number ,
40
+ end : number ,
41
+ sortModel : SortModelItem [ ] ,
42
+ ) : Promise < TableData > => {
38
43
const requestKey = v4 ( ) ;
39
44
vscode . postMessage ( {
40
45
command : "request:loadData" ,
41
46
key : requestKey ,
42
- data : { start, end } ,
47
+ data : { start, end, sortModel } ,
43
48
} ) ;
44
49
45
50
return new Promise ( ( resolve , reject ) => {
@@ -103,23 +108,25 @@ const useDataViewer = () => {
103
108
const dataSource = {
104
109
rowCount : undefined ,
105
110
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
+ } ) ;
123
130
} ,
124
131
} ;
125
132
0 commit comments