@@ -10,6 +10,7 @@ export interface SortByConfig {
10
10
disableMultiSort ?: boolean ;
11
11
isMultiSortEvent ?: ( event : Event ) => boolean ;
12
12
toggleOrder ?: ( 'asc' | 'desc' | undefined ) [ ] ;
13
+ serverSide ?: boolean ;
13
14
}
14
15
15
16
const DEFAULT_TOGGLE_ORDER : ( 'asc' | 'desc' | undefined ) [ ] = [ 'asc' , 'desc' , undefined ] ;
@@ -168,6 +169,7 @@ export const addSortBy =
168
169
disableMultiSort = false ,
169
170
isMultiSortEvent = isShiftClick ,
170
171
toggleOrder,
172
+ serverSide = false ,
171
173
} : SortByConfig = { } ) : TablePlugin < Item , SortByState < Item > , SortByColumnOptions , SortByPropSet > =>
172
174
( { columnOptions } ) => {
173
175
const disabledSortIds = Object . entries ( columnOptions )
@@ -176,18 +178,17 @@ export const addSortBy =
176
178
177
179
const sortKeys = createSortKeysStore ( initialSortKeys ) ;
178
180
const preSortedRows = writable < BodyRow < Item > [ ] > ( [ ] ) ;
179
- const sortedRows = writable < BodyRow < Item > [ ] > ( [ ] ) ;
181
+ // const sortedRows = writable<BodyRow<Item>[]>([]);
180
182
181
183
const deriveRows : DeriveRowsFn < Item > = ( rows ) => {
182
184
return derived ( [ rows , sortKeys ] , ( [ $rows , $sortKeys ] ) => {
183
185
preSortedRows . set ( $rows ) ;
184
- const _sortedRows = getSortedRows < Item , typeof $rows [ number ] > (
185
- $rows ,
186
- $sortKeys ,
187
- columnOptions
188
- ) ;
189
- sortedRows . set ( _sortedRows ) ;
190
- return _sortedRows ;
186
+ if ( serverSide ) {
187
+ return getSortedRows < Item , typeof $rows [ number ] > ( $rows , $sortKeys , columnOptions ) ;
188
+ } else {
189
+ return $rows ;
190
+ }
191
+ //sortedRows.set(_sortedRows);
191
192
} ) ;
192
193
} ;
193
194
0 commit comments