@@ -178,11 +178,7 @@ class GridSelectionColumnElement extends GridColumnElement {
178178 return ;
179179 }
180180
181- if ( this . __gridUsesArrayDataProvider ( ) && selectAll ) {
182- this . __withFilteredItemsArray ( ( items ) => ( this . _grid . selectedItems = items ) ) ;
183- } else {
184- this . _grid . selectedItems = [ ] ;
185- }
181+ this . _grid . selectedItems = selectAll && Array . isArray ( this . _grid . items ) ? this . __getRootLevelItems ( ) : [ ] ;
186182 }
187183
188184 /**
@@ -249,54 +245,33 @@ class GridSelectionColumnElement extends GridColumnElement {
249245 this . __previousActiveItem = activeItem ;
250246 }
251247
248+ /** @private */
249+ __getRootLevelItems ( ) {
250+ const rootCache = this . _grid . _cache ;
251+ return [ ...Array ( rootCache . size ) ] . map ( ( _ , idx ) => rootCache . items [ idx ] ) ;
252+ }
253+
252254 /** @private */
253255 __onSelectedItemsChanged ( ) {
254256 this . _selectAllChangeLock = true ;
255- if ( this . __gridUsesArrayDataProvider ( ) ) {
256- this . __withFilteredItemsArray ( ( items ) => {
257- if ( ! this . _grid . selectedItems . length ) {
258- this . selectAll = false ;
259- this . __indeterminate = false ;
260- } else if ( this . __arrayContains ( this . _grid . selectedItems , items ) ) {
261- this . selectAll = true ;
262- this . __indeterminate = false ;
263- } else {
264- this . selectAll = false ;
265- this . __indeterminate = true ;
266- }
267- } ) ;
257+ if ( Array . isArray ( this . _grid . items ) ) {
258+ if ( ! this . _grid . selectedItems . length ) {
259+ this . selectAll = false ;
260+ this . __indeterminate = false ;
261+ } else if ( this . __arrayContains ( this . _grid . selectedItems , this . __getRootLevelItems ( ) ) ) {
262+ this . selectAll = true ;
263+ this . __indeterminate = false ;
264+ } else {
265+ this . selectAll = false ;
266+ this . __indeterminate = true ;
267+ }
268268 }
269269 this . _selectAllChangeLock = false ;
270270 }
271271
272272 /** @private */
273273 __onDataProviderChanged ( ) {
274- this . __selectAllHidden = ! this . __gridUsesArrayDataProvider ( ) ;
275- }
276-
277- /**
278- * Assuming the grid uses an items array data provider, fetches all the filtered items
279- * from the data provider and invokes the callback with the resulting array.
280- *
281- * @private
282- **/
283- __withFilteredItemsArray ( callback ) {
284- const params = {
285- page : 0 ,
286- pageSize : Infinity ,
287- sortOrders : [ ] ,
288- filters : this . _grid . _mapFilters ( )
289- } ;
290- this . _grid . dataProvider ( params , ( items ) => callback ( items ) ) ;
291- }
292-
293- /**
294- * Checks whether the grid's dataProvider is an array data provider
295- *
296- * @private
297- **/
298- __gridUsesArrayDataProvider ( ) {
299- return this . _grid . _arrayDataProvider ;
274+ this . __selectAllHidden = ! Array . isArray ( this . _grid . items ) ;
300275 }
301276}
302277
0 commit comments