Skip to content

Commit 1776ebb

Browse files
authored
Merge pull request #7895 from IgniteUI/ddincheva/rowSelectionBugFixs-10.0
Fix(rowSelection): header check box state when there is row pinning or transactions -- 10.0.x
2 parents 2bfe80c + 5e60752 commit 1776ebb

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,19 @@ 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+
GridSelectionFunctions.verifyHeaderRowCheckboxState(fix, true, false);
1717+
expect(grid.selectedRows().length).toBe(grid.data.length);
1718+
});
17061719
});
17071720

17081721
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
@@ -728,8 +728,12 @@ export class IgxGridSelectionService {
728728

729729
/** Returns all data in the grid, with applied filtering and sorting and without deleted rows. */
730730
public get allData(): Array<any> {
731-
const allData = this.isFilteringApplied() || this.grid.sortingExpressions.length ?
732-
this.grid.filteredSortedData : this.grid.gridAPI.get_all_data(true);
731+
let allData;
732+
if (this.isFilteringApplied() || this.grid.sortingExpressions.length) {
733+
allData = this.grid.pinnedRecordsCount ? this.grid._filteredSortedUnpinnedData : this.grid.filteredSortedData;
734+
} else {
735+
allData = this.grid.gridAPI.get_all_data(true);
736+
}
733737
return allData.filter(rData => !this.isRowDeleted(this.grid.gridAPI.get_row_id(rData)));
734738
}
735739

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
@@ -597,6 +597,17 @@ describe('IgxTreeGrid - Selection #tGrid', () => {
597597
TreeGridFunctions.verifyHeaderCheckboxSelection(fix, true);
598598
});
599599

600+
it('should have correct header checkbox when add a row and then selectAll rows', () => {
601+
treeGrid.addRow({ ID: 13, Name: 'Michael Cooper', Age: 33, OnPTO: false }, 317);
602+
fix.detectChanges();
603+
604+
TreeGridFunctions.clickHeaderRowSelectionCheckbox(fix);
605+
fix.detectChanges();
606+
607+
expect(treeGrid.selectedRows().length).toBeGreaterThan(treeGrid.flatData.length);
608+
TreeGridFunctions.verifyHeaderCheckboxSelection(fix, true);
609+
});
610+
600611
it('should have correct header checkbox when add a row and undo transaction', fakeAsync(() => {
601612
treeGrid.addRow({ ID: 13, Name: 'Michael Cooper', Age: 33, OnPTO: false }, 317);
602613
tick();

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)