Skip to content

Commit cc0b0ef

Browse files
authored
Merge pull request #7896 from IgniteUI/ddincheva/rowSelectionBugFixs-9.1
Fix(rowSelection): header check box state when there is row pinning or transactions - 9.1.x
2 parents 36f570e + ce03328 commit cc0b0ef

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

projects/igniteui-angular/src/lib/grids/grid/grid-row-selection.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,20 @@ describe('IgxGrid - Row Selection #grid', () => {
17031703
expect(grid.selectedRows().length).toBe(9);
17041704
GridSelectionFunctions.verifyHeaderRowCheckboxState(grid, false, true);
17051705
}));
1706+
1707+
it('Row Pinning: should update checkbox status correctly when there is pinned row and groupBy', () => {
1708+
grid.pinRow(2);
1709+
fix.detectChanges();
1710+
1711+
grid.groupBy({ fieldName: 'InStock', dir: SortingDirection.Desc, ignoreCase: false });
1712+
fix.detectChanges();
1713+
1714+
GridSelectionFunctions.headerCheckboxClick(grid);
1715+
fix.detectChanges();
1716+
1717+
GridSelectionFunctions.verifyHeaderRowCheckboxState(fix, true, false);
1718+
expect(grid.selectedRows().length).toBe(grid.data.length);
1719+
});
17061720
});
17071721

17081722
describe('Integration with CRUD and transactions', () => {

projects/igniteui-angular/src/lib/grids/selection/selection.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,12 @@ export class IgxGridSelectionService {
725725

726726
/** Returns all data in the grid, with applied filtering and sorting and without deleted rows. */
727727
public get allData(): Array<any> {
728-
const allData = this.isFilteringApplied() || this.grid.sortingExpressions.length ?
729-
this.grid.filteredSortedData : this.grid.gridAPI.get_all_data(true);
728+
let allData;
729+
if (this.isFilteringApplied() || this.grid.sortingExpressions.length) {
730+
allData = this.grid.pinnedRecordsCount ? this.grid._filteredSortedUnpinnedData : this.grid.filteredSortedData;
731+
} else {
732+
allData = this.grid.gridAPI.get_all_data(true);
733+
}
730734
return allData.filter(rData => !this.isRowDeleted(this.grid.gridAPI.get_row_id(rData)));
731735
}
732736

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid-selection.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,17 @@ describe('IgxTreeGrid - Selection #tGrid', () => {
599599
TreeGridFunctions.verifyHeaderCheckboxSelection(fix, true);
600600
});
601601

602+
it('should have correct header checkbox when add a row and then selectAll rows', () => {
603+
treeGrid.addRow({ ID: 13, Name: 'Michael Cooper', Age: 33, OnPTO: false }, 317);
604+
fix.detectChanges();
605+
606+
TreeGridFunctions.clickHeaderRowSelectionCheckbox(fix);
607+
fix.detectChanges();
608+
609+
expect(treeGrid.selectedRows().length).toBeGreaterThan(treeGrid.flatData.length);
610+
TreeGridFunctions.verifyHeaderCheckboxSelection(fix, true);
611+
});
612+
602613
it('should have correct header checkbox when add a row and undo transaction', fakeAsync(() => {
603614
pending('Related to the bug #5673');
604615
treeGrid.addRow({ ID: 13, Name: 'Michael Cooper', Age: 33, OnPTO: false }, 317);

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.pipes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export class IgxTreeGridHierarchizingPipe implements PipeTransform {
3939
flatData, 0, treeGridRecordsMap);
4040
}
4141

42-
grid.flatData = flatData;
42+
grid.flatData = grid.transactions.enabled ?
43+
flatData.filter(rec => !grid.transactions.getState(this.getRowID(primaryKey, rec))) : flatData;
4344
grid.records = treeGridRecordsMap;
4445
grid.rootRecords = hierarchicalRecords;
4546
return hierarchicalRecords;

src/app/grid-row-pinning/grid-row-pinning.sample.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</div>
2121
<igx-grid [rowEditable]="true" [igxGridState]="options" [allowFiltering]='true' [primaryKey]='"ID"' [pinning]="pinningConfig" [paging]="true"
2222
[columnHiding]='true' [showToolbar]='true' [columnPinning]='true' #grid1 [data]="data" [width]="'800px'"
23-
[height]="'600px'" [rowSelection]="true">
23+
[height]="'600px'" [rowSelection]="'multiple'">
2424

2525
<ng-template igxGridDetail let-dataItem>
2626
<div>

0 commit comments

Comments
 (0)