File tree 2 files changed +34
-1
lines changed
2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -1180,7 +1180,7 @@ angular.module('ui.grid')
1180
1180
}
1181
1181
} ) ;
1182
1182
1183
- if ( self . selection ) {
1183
+ if ( self . selection && self . rows . length ) {
1184
1184
self . selection . selectAll = allRowsSelected ;
1185
1185
}
1186
1186
Original file line number Diff line number Diff line change @@ -530,6 +530,39 @@ describe('Grid factory', function () {
530
530
} ) ;
531
531
} ) ;
532
532
533
+ describe ( 'selection' , function ( ) {
534
+ var grid ;
535
+
536
+ beforeEach ( function ( ) {
537
+ grid = new Grid ( { id : 1 , enableRowHashing : false } ) ;
538
+ spyOn ( grid , 'getRow' ) . and . callFake ( function ( newEntity ) {
539
+ return newEntity ;
540
+ } ) ;
541
+
542
+ grid . rows = [ ] ;
543
+ grid . selection = { selectAll : false } ;
544
+ } ) ;
545
+ afterEach ( function ( ) {
546
+ grid . getRow . calls . reset ( ) ;
547
+ } ) ;
548
+
549
+ it ( 'should enable selectAll if a new row is added that is already selected' , function ( ) {
550
+ grid . modifyRows ( [ { isSelected : true } ] ) ;
551
+
552
+ expect ( grid . selection . selectAll ) . toBe ( true ) ;
553
+ } ) ;
554
+ it ( 'should disable selectAll if a new row is added that is not selected' , function ( ) {
555
+ grid . modifyRows ( [ { isSelected : false } ] ) ;
556
+
557
+ expect ( grid . selection . selectAll ) . toBe ( false ) ;
558
+ } ) ;
559
+ it ( 'should not update selectAll if there are no rows' , function ( ) {
560
+ grid . modifyRows ( [ ] ) ;
561
+
562
+ expect ( grid . selection . selectAll ) . toBe ( false ) ;
563
+ } ) ;
564
+ } ) ;
565
+
533
566
describe ( 'follow source array' , function ( ) {
534
567
var dataRows , grid ;
535
568
You can’t perform that action at this time.
0 commit comments