@@ -174,3 +174,128 @@ describe('when keyExpr is missing', () => {
174174 } ) ;
175175 } ) ;
176176} ) ;
177+
178+ describe ( 'selectAll with filters' , ( ) => {
179+ it ( 'should select only cards matching filterValue' , ( ) => {
180+ const cardView = setup ( {
181+ keyExpr : 'id' ,
182+ columns : [ 'id' , 'category' ] ,
183+ dataSource : [
184+ { id : 1 , category : 'A' } ,
185+ { id : 2 , category : 'A' } ,
186+ { id : 3 , category : 'B' } ,
187+ { id : 4 , category : 'B' } ,
188+ ] ,
189+ selection : {
190+ mode : 'multiple' ,
191+ allowSelectAll : true ,
192+ } ,
193+ filterPanel : {
194+ filterEnabled : true ,
195+ } ,
196+ } ) ;
197+
198+ cardView . option ( 'filterValue' , [ 'category' , '=' , 'A' ] ) ;
199+ cardView . selectAll ( ) ;
200+
201+ expect ( cardView . getSelectedCardKeys ( ) ) . toEqual ( [ 1 , 2 ] ) ;
202+ } ) ;
203+
204+ it ( 'should select only cards matching headerFilter' , ( ) => {
205+ const cardView = setup ( {
206+ keyExpr : 'id' ,
207+ columns : [ 'id' , 'category' ] ,
208+ dataSource : [
209+ { id : 1 , category : 'A' } ,
210+ { id : 2 , category : 'A' } ,
211+ { id : 3 , category : 'B' } ,
212+ { id : 4 , category : 'B' } ,
213+ ] ,
214+ selection : {
215+ mode : 'multiple' ,
216+ allowSelectAll : true ,
217+ } ,
218+ filterPanel : {
219+ filterEnabled : true ,
220+ } ,
221+ } ) ;
222+
223+ cardView . columnOption ( 'category' , 'filterValues' , [ 'A' ] ) ;
224+ cardView . selectAll ( ) ;
225+
226+ expect ( cardView . getSelectedCardKeys ( ) ) . toEqual ( [ 1 , 2 ] ) ;
227+ } ) ;
228+
229+ it ( 'should select only cards matching dataSource.filter()' , ( ) => {
230+ const cardView = setup ( {
231+ keyExpr : 'id' ,
232+ columns : [ 'id' , 'category' ] ,
233+ dataSource : [
234+ { id : 1 , category : 'A' } ,
235+ { id : 2 , category : 'A' } ,
236+ { id : 3 , category : 'B' } ,
237+ { id : 4 , category : 'B' } ,
238+ ] ,
239+ selection : {
240+ mode : 'multiple' ,
241+ allowSelectAll : true ,
242+ } ,
243+ filterPanel : {
244+ filterEnabled : true ,
245+ } ,
246+ } ) ;
247+
248+ cardView . getDataSource ( ) . filter ( [ 'category' , '=' , 'A' ] ) ;
249+ cardView . selectAll ( ) ;
250+
251+ expect ( cardView . getSelectedCardKeys ( ) ) . toEqual ( [ 1 , 2 ] ) ;
252+ } ) ;
253+
254+ it ( 'should select only cards matching filterValue, headerFilter and dataSource.filter()' , ( ) => {
255+ const cardView = setup ( {
256+ keyExpr : 'id' ,
257+ columns : [ 'id' , 'category1' , 'category2' , 'category3' ] ,
258+ dataSource : [
259+ {
260+ id : 1 , category1 : 'A' , category2 : '1' , category3 : true ,
261+ } ,
262+ {
263+ id : 2 , category1 : 'A' , category2 : '1' , category3 : false ,
264+ } ,
265+ {
266+ id : 3 , category1 : 'A' , category2 : '2' , category3 : true ,
267+ } ,
268+ {
269+ id : 4 , category1 : 'A' , category2 : '2' , category3 : false ,
270+ } ,
271+ {
272+ id : 5 , category1 : 'B' , category2 : '3' , category3 : true ,
273+ } ,
274+ {
275+ id : 6 , category1 : 'B' , category2 : '3' , category3 : false ,
276+ } ,
277+ {
278+ id : 7 , category1 : 'B' , category2 : '4' , category3 : true ,
279+ } ,
280+ {
281+ id : 8 , category1 : 'B' , category2 : '4' , category3 : false ,
282+ } ,
283+ ] ,
284+ selection : {
285+ mode : 'multiple' ,
286+ allowSelectAll : true ,
287+ } ,
288+ filterPanel : {
289+ filterEnabled : true ,
290+ } ,
291+ } ) ;
292+
293+ cardView . option ( 'filterValue' , [ 'category1' , '=' , 'A' ] ) ;
294+ cardView . columnOption ( 'category2' , 'filterValues' , [ '1' ] ) ;
295+ cardView . getDataSource ( ) . filter ( [ 'category3' , '=' , true ] ) ;
296+
297+ cardView . selectAll ( ) ;
298+
299+ expect ( cardView . getSelectedCardKeys ( ) ) . toEqual ( [ 1 ] ) ;
300+ } ) ;
301+ } ) ;
0 commit comments