Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(grid): row selection templating #4998 #5558

Merged
merged 78 commits into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
3c8c632
feat(grid): add grid row-selection templating #4998
jackofdiamond5 Jul 30, 2019
be86bb9
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
jackofdiamond5 Jul 31, 2019
653ee56
feat(tree-grid): add row-selection templating #4998
jackofdiamond5 Aug 1, 2019
e62df92
refactor(grid): replace any with strict types; update HeadSelectorSta…
jackofdiamond5 Aug 1, 2019
d485d5c
test(grid): initial test spec file #4998
Lipata Aug 1, 2019
8de532b
refactor(grid/tree-grid): expose selectedCount, totalCount in head co…
jackofdiamond5 Aug 2, 2019
c7b3211
Merge branch 'bpenkov/row-selection-templating' of https://github.com…
jackofdiamond5 Aug 2, 2019
814844c
refactor(grid-base): expose selectedRowsCount and totalRowsCount
jackofdiamond5 Aug 2, 2019
ee7b766
feat(hgrid): add row-selection templating #4998
jackofdiamond5 Aug 2, 2019
bcb3ef3
test(grid-selection): update should select all rows programatically #…
jackofdiamond5 Aug 8, 2019
83559e4
refactor(igx-selection): pass TemplateRef to directives' constructors
jackofdiamond5 Aug 8, 2019
19559c2
refactor(grid): remove unneeded public props; keep row index on grid …
jackofdiamond5 Aug 8, 2019
261f035
refactor(treeGrid): remove unneeded public props; keep row index on g…
jackofdiamond5 Aug 8, 2019
9042d55
refactor(hgrid): root grid and row islands can template selectors sep…
jackofdiamond5 Aug 8, 2019
128f3ee
refactor(grid-common): add IgxSelectorsModule to exports arr
jackofdiamond5 Aug 9, 2019
b95740e
refactor(grid/tree-grid/hgrid): use grid.data in head context
jackofdiamond5 Aug 9, 2019
5d7a2e4
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
jackofdiamond5 Aug 12, 2019
c8ca67a
refactor(grid): use indexes from filteredSortedData for row numbering
jackofdiamond5 Aug 16, 2019
35dea3c
refactor(hgrid/hgrid-row): include row selection methods in header/ro…
jackofdiamond5 Aug 16, 2019
3040e08
chore(grid): fix lint errors
jackofdiamond5 Aug 19, 2019
75ad7a7
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
jackofdiamond5 Aug 19, 2019
37a7e66
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
jackofdiamond5 Aug 20, 2019
1166711
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
jackofdiamond5 Aug 21, 2019
55ae1ef
test(row-selection): move initial test spec to grid-row-selection.spe…
jackofdiamond5 Aug 22, 2019
b052d11
chore(grid-base;tree-grid): import DeprecateProperty; use onHeadSelec…
jackofdiamond5 Aug 22, 2019
6beb4d1
refactor(row-selection.spec): add test components to testbed declarat…
jackofdiamond5 Aug 22, 2019
3cd6003
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
jackofdiamond5 Aug 22, 2019
7d40582
docs(grid-base): document rowSelectorTemplate & headSelectorTemplate …
jackofdiamond5 Aug 22, 2019
4632c0e
refactor(row.component): remove redundant rowSelected property
jackofdiamond5 Aug 22, 2019
a905a95
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
jackofdiamond5 Aug 22, 2019
824b6fb
refactor(grid-base): use grid.selectedRows in context; remove selecte…
jackofdiamond5 Aug 22, 2019
1704404
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
jackofdiamond5 Aug 22, 2019
48764f0
refactor(tree-grid): use records.size in context
jackofdiamond5 Aug 22, 2019
f62b46f
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
jackofdiamond5 Aug 23, 2019
763c83d
refactor(grid-base): rename headerCheckboxAriaLabel to headSelectorBa…
jackofdiamond5 Aug 23, 2019
85062bc
test(custom-selectors): update initial specs #4998
jackofdiamond5 Aug 23, 2019
d6ee9a7
refactor(hgrid-row): preserve 'this' in select/deselect methods
jackofdiamond5 Aug 23, 2019
fb2c69d
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
jackofdiamond5 Aug 23, 2019
ff25e66
chore(hgrid-sample-component): rename row island ref props
jackofdiamond5 Aug 23, 2019
c889e4a
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
jackofdiamond5 Aug 26, 2019
e05a349
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
jackofdiamond5 Aug 26, 2019
eb59e66
refactor(hgrid-row/tgrid-row): use selected getter in context
jackofdiamond5 Aug 26, 2019
f3cb871
Merge branch 'master' into bpenkov/row-selection-templating
wnvko Aug 26, 2019
7b84814
Merge branch 'bpenkov/row-selection-templating' of https://github.com…
jackofdiamond5 Aug 27, 2019
28e8719
test(hgrid): add test scenarios #5558
jackofdiamond5 Aug 28, 2019
38228d3
Merge branch 'nrobakova/hgrid-rowSelection-tests' of https://github.c…
jackofdiamond5 Aug 28, 2019
fd58b83
refactor(grid-base): remove unneeded property; hide rowSelectorsTemplate
jackofdiamond5 Aug 28, 2019
02f5cd7
Merge branch 'master' into bpenkov/row-selection-templating
Lipata Aug 28, 2019
e063c5a
test(grid): Adding igxGrid selection tests #4998
dafo Aug 29, 2019
1a5a00c
Merge branch 'bpenkov/row-selection-templating' of https://github.com…
dafo Aug 29, 2019
b254d1c
test(grid): Adding a selection test #4998
dafo Aug 29, 2019
ebe144a
test(grid): Removing a fit #4998
dafo Aug 29, 2019
c64e6d4
test(grid): Adding tree grid selection tests #4498
dafo Aug 29, 2019
495c9e4
test(hGrid): update test scenarios #4998
jackofdiamond5 Aug 29, 2019
90af219
refactor(hGrid): move click handler to div; add markForCheck #4998
jackofdiamond5 Aug 29, 2019
b6bfe97
Merge branch 'bpenkov/row-selection-templating' of https://github.com…
jackofdiamond5 Aug 29, 2019
0f28e91
chore(tGrid): fix lint erros in tests
jackofdiamond5 Aug 29, 2019
24d4dfa
chore(tGrid/grid): fix lint errors
jackofdiamond5 Aug 29, 2019
e190ede
refactor(tGrid-row): move click handler on div
jackofdiamond5 Aug 30, 2019
72dafa2
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
jackofdiamond5 Aug 30, 2019
d475a4a
docs(hGrid-row): document select, deselect methods;
jackofdiamond5 Aug 30, 2019
d45b8e6
docs(row-sel-templating): update changelog
jackofdiamond5 Aug 30, 2019
10ec54e
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
jackofdiamond5 Aug 30, 2019
989debe
chore(grid-samples.spec): include OnInit in imports
jackofdiamond5 Aug 30, 2019
c054b70
Merge branch 'master' into bpenkov/row-selection-templating
jackofdiamond5 Sep 2, 2019
46b5ad4
chore(*): delete package-lock,json
jackofdiamond5 Sep 2, 2019
023ccba
chore(*): revert package-lock.json
jackofdiamond5 Sep 2, 2019
da21b2d
docs(grid-base): set row and head selector template getters to hidden…
jackofdiamond5 Sep 2, 2019
14673eb
Merge branch 'master' into bpenkov/row-selection-templating
jackofdiamond5 Sep 2, 2019
a68197e
Merge branch 'bpenkov/row-selection-templating' of https://github.com…
jackofdiamond5 Sep 2, 2019
1ac0a1c
refactor(grid-base): rename rowSelectorsTemplate/headSelectorsTemplate
jackofdiamond5 Sep 2, 2019
7c87a60
refactor(grid/tGrid/hGrid): apply requested changes
jackofdiamond5 Sep 2, 2019
3dba085
chore(grid-selection): rename filteredAndSelectedData method
jackofdiamond5 Sep 3, 2019
216f5a0
refactor(grid/tGrid/hGrid): apply requested changes
jackofdiamond5 Sep 3, 2019
8c1c20d
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
jackofdiamond5 Sep 3, 2019
7af3945
Merge branch 'master' into bpenkov/row-selection-templating
Lipata Sep 3, 2019
50dd034
refactor(grid/tGrid/hGrid): apply requested changes
jackofdiamond5 Sep 3, 2019
059bf38
Merge branch 'bpenkov/row-selection-templating' of https://github.com…
jackofdiamond5 Sep 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ For more information about the theming please read our [documentation](https://w
- `uniqueColumnValuesStrategy` input is added. This property provides a callback for loading unique column values on demand. If this property is provided, the unique values it generates will be used by the Excel Style Filtering (instead of using the unique values from the data that is bound to the grid).
- `igxExcelStyleLoading` directive is added, which can be used to provide a custom loading template for the Excel Style Filtering. If this property is not provided, a default loading template will be used instead.
- introduced new properties `cellSelection` and `rowSelection` which accept GridSelection mode enumeration. Grid selection mode could be none, single or multiple. Also `hideRowSelectors` property is added, which allows you to show and hide row selectors when row selection is enabled.
- introduced functionality for templating row and header selectors - [spec](https://github.com/IgniteUI/igniteui-angular/wiki/Row-Selection-Templating-(Grid-feature))
```html
<igx-grid [data]="data", [rowSelection]="'multiple'" primaryKey="ID">
<igx-column field="Name"></igx-column>
<igx-column field="Age"></igx-column>

<ng-template igxHeadSelector let-headSelector>
<igx-icon>done_all</igx-icon>
</ng-template>
<ng-template igxRowSelector let-rowContext>
<igx-switch [checked]="rowContext.selected"></igx-switch>
</ng-template>
</igx-grid>
```
- `IgxHierarchicalGrid`
- Row Islands now emit child grid events with an additional argument - `owner`, which holds reference to the related child grid component instance.
- `IgxDrag`
Expand Down
6 changes: 6 additions & 0 deletions projects/igniteui-angular/src/lib/core/grid-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,12 @@ export class IgxGridSelectionService {
return this.rowSelection.size > 0 && filteredData && !this.areAllRowSelected();
}

public get filteredSelectedRowIds(): any[] {
return this.isFilteringApplied() ?
this.getRowIDs(this.allData).filter(rowID => this.isRowSelected(rowID)) :
this.getSelectedRows().filter(rowID => !this.isRowDeleted(rowID));
}

public emitRowSelectionEvent(newSelection, added, removed, event?): boolean {
const currSelection = this.getSelectedRows();
if (this.areEqualCollections(currSelection, newSelection)) { return; }
Expand Down
109 changes: 84 additions & 25 deletions projects/igniteui-angular/src/lib/grids/grid-base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import {
VerticalAlignment,
IgxOverlayService
} from '../services/index';
import { IgxCheckboxComponent } from './../checkbox/checkbox.component';
import { GridBaseAPIService } from './api.service';
import { IgxGridCellComponent } from './cell.component';
import { IColumnVisibilityChangedEventArgs } from './column-hiding-item.directive';
Expand Down Expand Up @@ -89,8 +88,9 @@ import {
import { IgxGridColumnResizerComponent } from './grid-column-resizer.component';
import { IgxGridFilteringRowComponent } from './filtering/grid-filtering-row.component';
import { IgxDragDirective } from '../directives/drag-drop/drag-drop.directive';
import { DeprecateProperty } from '../core/deprecateDecorators';
import { CharSeparatedValueData } from '../services/csv/char-separated-value-data';
import { IgxHeadSelectorDirective, IgxRowSelectorDirective } from './igx-row-selectors.module';
import { DeprecateProperty } from '../core/deprecateDecorators';

const MINIMUM_COLUMN_WIDTH = 136;
const FILTER_ROW_HEIGHT = 50;
Expand Down Expand Up @@ -259,6 +259,7 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
private _locale = null;
public _destroyed = false;
private overlayIDs = [];

private _hostWidth;
/**
* An accessor that sets the resource strings.
Expand Down Expand Up @@ -1707,9 +1708,51 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
return this.toolbarCustomContentTemplates.first;
}

/**
* @hidden
* @internal
*/
@ContentChildren(IgxGridToolbarCustomContentDirective, { read: IgxGridToolbarCustomContentDirective, descendants: false })
public toolbarCustomContentTemplates: QueryList<IgxGridToolbarCustomContentDirective>;

/**
* @hidden
* @internal
*/
public get headSelectorTemplate(): TemplateRef<IgxHeadSelectorDirective> {
if (this.headSelectorsTemplates && this.headSelectorsTemplates.first) {
return this.headSelectorsTemplates.first.templateRef;
}

return null;
}

/**
* @hidden
* @internal
*/
@ContentChildren(IgxHeadSelectorDirective, { read: IgxHeadSelectorDirective, descendants: false })
public headSelectorsTemplates: QueryList<IgxHeadSelectorDirective>;

/**
* @hidden
* @internal
*/
public get rowSelectorTemplate(): TemplateRef<IgxRowSelectorDirective> {
if (this.rowSelectorsTemplates && this.rowSelectorsTemplates.first) {
return this.rowSelectorsTemplates.first.templateRef;
}

return null;
}

/**
* @hidden
* @internal
*/
@ContentChildren(IgxRowSelectorDirective, { read: IgxRowSelectorDirective, descendants: false })
jackofdiamond5 marked this conversation as resolved.
Show resolved Hide resolved
public rowSelectorsTemplates: QueryList<IgxRowSelectorDirective>;

/**
* @hidden
*/
Expand Down Expand Up @@ -1743,8 +1786,8 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
/**
* @hidden
*/
@ViewChild('headerCheckboxContainer', { static: false })
public headerCheckboxContainer: ElementRef;
@ViewChild('headerSelectorContainer', { static: false })
public headerSelectorContainer: ElementRef;

/**
* @hidden
Expand All @@ -1758,12 +1801,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
@ViewChild('headerGroupContainer', { static: false })
public headerGroupContainer: ElementRef;

/**
* @hidden
*/
@ViewChild('headerCheckbox', { read: IgxCheckboxComponent, static: false })
public headerCheckbox: IgxCheckboxComponent;

/**
* @hidden
*/
Expand Down Expand Up @@ -1841,6 +1878,7 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
*/
@ViewChild('defaultRowEditTemplate', { read: TemplateRef, static: true })
private defaultRowEditTemplate: TemplateRef<any>;

/**
* @hidden
*/
Expand Down Expand Up @@ -3337,10 +3375,18 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
return totalWidth;
}

get showRowCheckboxes(): boolean {
/**
* @hidden
* @internal
*/
get showRowSelectors(): boolean {
jackofdiamond5 marked this conversation as resolved.
Show resolved Hide resolved
return this.isRowSelectable && this.hasVisibleColumns && !this.hideRowSelectors;
}

/**
* @hidden
* @internal
*/
get showDragIcons(): boolean {
return this.rowDraggable && this.columns.length > this.hiddenColumnsCount;
}
Expand Down Expand Up @@ -4167,7 +4213,7 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
const pagingHeight = this.getPagingHeight();
const groupAreaHeight = this.getGroupAreaHeight();
const renderedHeight = toolbarHeight + this.theadRow.nativeElement.offsetHeight +
footerHeight + pagingHeight + groupAreaHeight +
footerHeight + pagingHeight + groupAreaHeight +
this.scr.nativeElement.clientHeight;

const computed = this.document.defaultView.getComputedStyle(this.nativeElement).getPropertyValue('height');
Expand Down Expand Up @@ -4476,7 +4522,7 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
let width = 0;

if (this.isRowSelectable) {
width += this.headerCheckboxContainer ? this.headerCheckboxContainer.nativeElement.getBoundingClientRect().width : 0;
width += this.headerSelectorContainer ? this.headerSelectorContainer.nativeElement.getBoundingClientRect().width : 0;
}
if (this.rowDraggable) {
width += this.headerDragContainer ? this.headerDragContainer.nativeElement.getBoundingClientRect().width : 0;
Expand Down Expand Up @@ -4685,10 +4731,24 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
/**
* @hidden
*/
get headerCheckboxAriaLabel() {
return this._filteringExpressionsTree.filteringOperands.length > 0 ?
this.headerCheckbox && this.selectionService.areAllRowSelected() ? 'Deselect all filtered' : 'Select all filtered' :
this.headerCheckbox && this.selectionService.areAllRowSelected() ? 'Deselect all' : 'Select all';
get headSelectorBaseAriaLabel() {
if (this._filteringExpressionsTree.filteringOperands.length > 0) {
return this.selectionService.areAllRowSelected() ? 'Deselect all filtered' : 'Select all filtered';
}

return this.selectionService.areAllRowSelected() ? 'Deselect all' : 'Select all';
}

/**
* @hidden
* @internal
*/
public get totalRowsCountAfterFilter() {
if (this.data) {
return this.selectionService.allData.length;
}

return 0;
}

/**
Expand Down Expand Up @@ -4875,7 +4935,7 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
if (col) {
const key = headers ? col.header || col.field : col.field;
record[key] = formatters && col.formatter ? col.formatter(source[row][col.field])
: source[row][col.field];
: source[row][col.field];
}
});
}
Expand All @@ -4890,15 +4950,15 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
protected getSelectableColumnsAt(index) {
if (this.hasColumnLayouts) {
const visibleLayoutColumns = this.visibleColumns
.filter(col => col.columnLayout)
.sort((a, b) => a.visibleIndex - b.visibleIndex);
.filter(col => col.columnLayout)
.sort((a, b) => a.visibleIndex - b.visibleIndex);
const colLayout = visibleLayoutColumns[index];
return colLayout ? colLayout.children.toArray() : [];
} else {
const visibleColumns = this.visibleColumns
.filter(col => !col.columnGroup)
.sort((a, b) => a.visibleIndex - b.visibleIndex);
return [ visibleColumns[index] ];
.filter(col => !col.columnGroup)
.sort((a, b) => a.visibleIndex - b.visibleIndex);
return [visibleColumns[index]];
}
}

Expand All @@ -4913,7 +4973,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
return this.extractDataFromSelection(source, formatters, headers);
}


/**
* @hidden
*/
Expand Down Expand Up @@ -4944,7 +5003,7 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
this.onGridCopy.emit(ev);

if (ev.cancel) {
return;
return;
}

const transformer = new CharSeparatedValueData(ev.data, this.clipboardOptions.separator);
Expand Down
7 changes: 5 additions & 2 deletions projects/igniteui-angular/src/lib/grids/grid-common.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import { IgxGridExcelStyleFilteringModule } from './filtering/excel-style/grid.e
import { IgxGridDragSelectDirective } from './drag-select.directive';
import { IgxGridColumnResizerComponent } from './grid-column-resizer.component';
import { IgxRowDragModule } from './row-drag.directive';
import { IgxRowSelectorsModule } from './igx-row-selectors.module';
/**
* @hidden
*/
Expand Down Expand Up @@ -164,7 +165,8 @@ import { IgxRowDragModule } from './row-drag.directive';
IgxFilterCellTemplateDirective,
IgxRowDragModule,
IgxPaginatorModule,
IgxGridFooterComponent
IgxGridFooterComponent,
IgxRowSelectorsModule
],
imports: [
CommonModule,
Expand Down Expand Up @@ -193,7 +195,8 @@ import { IgxRowDragModule } from './row-drag.directive';
IgxGridPipesModule,
IgxGridExcelStyleFilteringModule,
IgxRowDragModule,
IgxPaginatorModule
IgxPaginatorModule,
IgxRowSelectorsModule
],
providers: [
IgxGridSelectionService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import {
SelectionWithScrollsComponent,
SingleRowSelectionComponent,
RowSelectionWithoutPrimaryKeyComponent,
SelectionWithTransactionsComponent
SelectionWithTransactionsComponent,
GridCustomSelectorsComponent
} from '../../test-utils/grid-samples.spec';
import { IgxHierarchicalGridModule } from '../hierarchical-grid/hierarchical-grid.module';
import { GridFunctions, GridSelectionFunctions } from '../../test-utils/grid-functions.spec';
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
import { IgxRowSelectorsModule } from '../igx-row-selectors.module';

const DEBOUNCETIME = 30;

Expand All @@ -31,12 +32,13 @@ describe('IgxGrid - Row Selection #grid', () => {
SelectionWithScrollsComponent,
RowSelectionWithoutPrimaryKeyComponent,
SingleRowSelectionComponent,
SelectionWithTransactionsComponent
SelectionWithTransactionsComponent,
GridCustomSelectorsComponent,
],
imports: [
NoopAnimationsModule,
IgxGridModule,
IgxHierarchicalGridModule
IgxRowSelectorsModule
]
})
.compileComponents();
Expand Down Expand Up @@ -1871,4 +1873,62 @@ describe('IgxGrid - Row Selection #grid', () => {
GridSelectionFunctions.verifyRowSelected(addedRow);
}));
});

describe('Custom selectors', () => {
let fix;
let grid;

beforeEach(fakeAsync(() => {
fix = TestBed.createComponent(GridCustomSelectorsComponent);
fix.detectChanges();
grid = fix.componentInstance.grid;
grid.rowSelection = GridSelectionMode.multiple;
}));

it('Should have the correct properties in the custom row selector template', () => {
const firstRow = grid.getRowByIndex(0);
const firstCheckbox = firstRow.nativeElement.querySelector('.igx-checkbox__composite');
const context = { index: 0, rowID: 'ALFKI', selected: false };
const contextUnselect = { index: 0, rowID: 'ALFKI', selected: true };
spyOn(fix.componentInstance, 'onRowCheckboxClick').and.callThrough();
firstCheckbox.click();
fix.detectChanges();

expect(fix.componentInstance.onRowCheckboxClick).toHaveBeenCalledTimes(1);
expect(fix.componentInstance.onRowCheckboxClick).toHaveBeenCalledWith(new MouseEvent('click'), context);

// Verify correct properties when unselecting a row
firstCheckbox.click();
fix.detectChanges();

expect(fix.componentInstance.onRowCheckboxClick).toHaveBeenCalledTimes(2);
expect(fix.componentInstance.onRowCheckboxClick).toHaveBeenCalledWith(new MouseEvent('click'), contextUnselect);
});

it('Should have the correct properties in the custom row selector header template', () => {
const context = { selectedCount: 0, totalCount: 27 };
const contextUnselect = { selectedCount: 27, totalCount: 27 };
const headerCheckbox = fix.nativeElement.querySelector('.igx-grid__thead').querySelector('.igx-checkbox__composite');
spyOn(fix.componentInstance, 'onHeaderCheckboxClick').and.callThrough();
headerCheckbox.click();
fix.detectChanges();

expect(fix.componentInstance.onHeaderCheckboxClick).toHaveBeenCalledTimes(1);
expect(fix.componentInstance.onHeaderCheckboxClick).toHaveBeenCalledWith(new MouseEvent('click'), context);

headerCheckbox.click();
fix.detectChanges();

expect(fix.componentInstance.onHeaderCheckboxClick).toHaveBeenCalledTimes(2);
expect(fix.componentInstance.onHeaderCheckboxClick).toHaveBeenCalledWith(new MouseEvent('click'), contextUnselect);
});

it('Should have correct indices on all pages', () => {
grid.nextPage();
fix.detectChanges();

const firstRootRow = grid.getRowByIndex(0);
expect(firstRootRow.nativeElement.querySelector('.rowNumber').textContent).toEqual('30');
});
});
});
Loading