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

Grid Selection --- 8.2.x #5651

Merged
merged 116 commits into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from 113 commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
8804ad4
feat(IgxGridSelection): initial cell/row selection implementation #4989
ddincheva Jul 24, 2019
f6da824
refactor(IgxGrid): remove selectionService and us gridSelection inste…
ddincheva Jul 24, 2019
fb2cefe
Merge branch '8.1.x' of https://github.com/IgniteUI/igniteui-angular …
ddincheva Jul 25, 2019
688739c
Merge branch '8.1.x' of https://github.com/IgniteUI/igniteui-angular …
ddincheva Jul 25, 2019
8abbeb5
refactor(IgxGrid): select row on pointer down #4989
ddincheva Jul 25, 2019
ed75814
merge 8.1.x
ddincheva Jul 26, 2019
889ca05
Merge branch '8.1.x' of https://github.com/IgniteUI/igniteui-angular …
ddincheva Jul 26, 2019
98f9c48
refactor(IgxGridAPI): use grid-selection service #4989
ddincheva Jul 29, 2019
ad8f376
chore(*): move logic around grid selection in grid-selection service
ddincheva Jul 29, 2019
1d5e0b1
chore(*): use rowSelection property instead rowSelectable
ddincheva Jul 29, 2019
33443ed
Merge branch '8.1.x' of https://github.com/IgniteUI/igniteui-angular …
ddincheva Jul 29, 2019
08c6aaa
Merge branch '8.1.x' of https://github.com/IgniteUI/igniteui-angular …
ddincheva Jul 30, 2019
7401e53
refactor(grid): organize selection tests in different describes
nrobakova Jul 30, 2019
66007f9
chore(*): Add cell selection none tests
nrobakova Jul 30, 2019
a8924d7
chore(*): add cell selection tests
nrobakova Jul 31, 2019
4d5fea0
Merge branch '8.1.x' of https://github.com/IgniteUI/igniteui-angular …
ddincheva Jul 31, 2019
f689629
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
ddincheva Jul 31, 2019
08fa431
Merge branch '8.1.x' of https://github.com/IgniteUI/igniteui-angular …
ddincheva Aug 5, 2019
2951fc7
feat(IgxGrid): deselect/select row on CRUD operations #4989
ddincheva Aug 5, 2019
dc016c7
feat(IgxRow): toggle row selection on click #4989
ddincheva Aug 5, 2019
4322617
chore(*): exxtend grid selection sample
ddincheva Aug 5, 2019
f47e144
fix(IgxGridSelection): select rows that are not in grid dataSource #…
ddincheva Aug 6, 2019
4c26505
feat(IgxCell): add/remove pointer event when cellSelectionMode is cha…
ddincheva Aug 6, 2019
45a8df4
feat(IgxGrid): allow row to be selected throung api #4989
ddincheva Aug 6, 2019
2525c2a
merge master
ddincheva Aug 6, 2019
8990c23
chore(*): rowSelection implementation with map
ddincheva Aug 8, 2019
e7d3a07
feat(IgxGridSelection): refactor row selection #4989
ddincheva Aug 8, 2019
282a2f3
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
ddincheva Aug 8, 2019
a7e911f
merge master
ddincheva Aug 9, 2019
71fd27d
refactor(grid): Update rowSelection tests
nrobakova Aug 12, 2019
55dbbee
fix(IgxTreeGrid): select multiple rows on shift + click #4989
ddincheva Aug 13, 2019
458e627
merge master
ddincheva Aug 13, 2019
bc79586
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
ddincheva Aug 13, 2019
d8edf4f
chore(*): update grid's templates to use new row selection logic
ddincheva Aug 13, 2019
6868449
chore(*): fix linting errors
ddincheva Aug 13, 2019
998d359
feat(IgxGridSelection): do not recalc are all rows selected #4989
ddincheva Aug 13, 2019
64385d8
feat(IgxGrid): emit onRowSelectionChange when perform row seletion #4989
ddincheva Aug 14, 2019
a05b312
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
ddincheva Aug 14, 2019
9435b80
fix(IgxTreeGrid): emit correctly onRowSelectionChange event #4989
ddincheva Aug 14, 2019
fe28aad
feat(IgxTreeGrid): don't consider deleted rows in calc of headerCbSta…
ddincheva Aug 15, 2019
8599a41
merge master
ddincheva Aug 15, 2019
8fa4e5d
refactor(grid): update rowSelection tests
nrobakova Aug 15, 2019
8ec4a37
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
nrobakova Aug 15, 2019
b21ba93
fix(IgxGrid): row selection with enabled transactions #4989
ddincheva Aug 15, 2019
03a3bca
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
ddincheva Aug 15, 2019
4a7b5d6
fix(IgxGrid): prevent row selection when click over drag indicator #4989
ddincheva Aug 15, 2019
771ca43
refactor(grid): update RowSelection tests
nrobakova Aug 15, 2019
cc09131
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
nrobakova Aug 15, 2019
21a9444
refactor(grid): update rowSelection tests
nrobakova Aug 15, 2019
f81cf22
refactor(GridSelection): update chackbox status when selection is can…
ddincheva Aug 15, 2019
d4eacbd
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
ddincheva Aug 15, 2019
362ecb3
feat(CellSelection): change cell selection runtime in hieararchical g…
ddincheva Aug 15, 2019
0708b95
refactor(grid): update rowSelection tests
nrobakova Aug 15, 2019
bedb6cb
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
nrobakova Aug 15, 2019
33103df
refactor(selection): update failing tests
nrobakova Aug 15, 2019
7087d74
feat(IgxHierarchicalGrid): should change row/cell selection run tim…
ddincheva Aug 16, 2019
fa97384
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
ddincheva Aug 16, 2019
a23a124
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
ddincheva Aug 16, 2019
7018293
chore(*): update selection tests
nrobakova Aug 16, 2019
78b7bb6
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
nrobakova Aug 16, 2019
3164b8c
feat(IgxGridSelection): run change detection when select though API #…
ddincheva Aug 19, 2019
b9b1879
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
ddincheva Aug 19, 2019
ba72a5c
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
ddincheva Aug 19, 2019
70caf4a
chore(grid): Update rowSelection tests
nrobakova Aug 19, 2019
fc6047f
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
nrobakova Aug 19, 2019
332a203
chore(treeGrid): Add tests for changing cellSelection in the treeGrid
nrobakova Aug 19, 2019
e19bf18
feat(IgxGrid): allow to override newSelection #4989
ddincheva Aug 19, 2019
f6c0f8d
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
ddincheva Aug 19, 2019
d5cc8f5
refactor(GridSelection): save active element - toggle #4989
ddincheva Aug 19, 2019
58ff581
chore(*): fix linting errors
ddincheva Aug 19, 2019
3b7c8eb
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
ddincheva Aug 20, 2019
85b02d8
chore(*): add new row selection tests
nrobakova Aug 20, 2019
af383bf
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
nrobakova Aug 20, 2019
f4d80e8
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
ddincheva Aug 20, 2019
a473d14
chore(*): update changelog with the new properties for row/cell selec…
ddincheva Aug 20, 2019
bcc569f
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
ddincheva Aug 20, 2019
029e699
chore(*): add base files for hgrid selection
nrobakova Aug 20, 2019
e0de23e
chore(*): refactor grid-selection service
ddincheva Aug 20, 2019
d7d4490
refactor(IgxGrid): change headerCB visibility according rowSelectionM…
ddincheva Aug 21, 2019
7fb51ba
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
ddincheva Aug 21, 2019
ce5f972
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
nrobakova Aug 21, 2019
7fafe91
chore(*): update rowSelection tests
nrobakova Aug 21, 2019
c415882
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
ddincheva Aug 21, 2019
f9cc690
chore(*): refactor selection service
ddincheva Aug 21, 2019
1069dcd
chore(*): update treeGrid tests
nrobakova Aug 21, 2019
c7823a4
refactor(GridSelection): handle row selection when click on rowSelect…
ddincheva Aug 22, 2019
2810c1c
chore(*): update selection tests
nrobakova Aug 22, 2019
e287488
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
ddincheva Aug 22, 2019
45dbabe
chore(*): Update clciking on rwo checkbox
nrobakova Aug 22, 2019
555b8fc
chore(*): update row selection tests
nrobakova Aug 22, 2019
86c3b72
chore(*): update failing rowSelection tests
nrobakova Aug 22, 2019
e679df3
chore(*): update changelog with changes in onRowSelectionChange event
ddincheva Aug 22, 2019
e9d83bb
merge master
ddincheva Aug 22, 2019
c58877a
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
ddincheva Aug 22, 2019
c5d9481
chore(*): add new row selection tests
nrobakova Aug 22, 2019
c92634b
merge master
nrobakova Aug 22, 2019
432f049
chore(*): update hgrid selection tests
nrobakova Aug 22, 2019
cc66d90
chore(*): add HelperUtils to groupBy tests
nrobakova Aug 22, 2019
7fa9700
chore(*): update aria attribute correctly on header checkbox
ddincheva Aug 22, 2019
603e4f8
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
ddincheva Aug 22, 2019
1f80cc6
chore(*): update header checkbox correctly in hierarchical grid
ddincheva Aug 22, 2019
fe7682e
chore(*): comment failing tests
nrobakova Aug 22, 2019
b1548ce
Merge branch 'master' into ddincheva/gridSelection
zdrawku Aug 22, 2019
7625cb2
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
ddincheva Aug 23, 2019
32d7770
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
ddincheva Aug 23, 2019
a5a7241
chore(*): addres pending issues and review comment
ddincheva Aug 23, 2019
9e736b7
merge master
ddincheva Aug 23, 2019
71fa80e
Merge branch 'master' into ddincheva/gridSelection
Lipata Aug 23, 2019
809f192
chore(*): address requested changes and comments
ddincheva Aug 23, 2019
4a097ad
Merge branch 'ddincheva/gridSelection' of https://github.com/IgniteUI…
ddincheva Aug 23, 2019
f534dda
merge master
ddincheva Aug 26, 2019
920085e
chore(*): allow to cnacel rowSelection Event
ddincheva Aug 26, 2019
b50b783
chore(*): change rowSelectable with isRowSelectable because is deprec…
ddincheva Aug 26, 2019
82cdc38
chore(*): update checkbox state when clear all rows or change selecti…
ddincheva Aug 26, 2019
6ce1564
Merge branch 'master' into ddincheva/gridSelection
zdrawku Aug 26, 2019
d23c272
Merge branch 'master' into ddincheva/gridSelection
zdrawku Aug 26, 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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes for each version of this project will be documented in this
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
- `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.
- `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 All @@ -24,9 +25,13 @@ All notable changes for each version of this project will be documented in this

### General
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
- `isCellSelected` method has been deprecated. Now you can use `selected` property.
- `rowSelectable` property has been deprecated. Now you can use `rowSelection` property to enable row selection and also you can show and hide the row selectors by setting `hideRowSelectors` property to true or false (which is the default value).
- Removed deprecated event `OnFocusChange`
- **Breaking Change** `igxExcelStyleSortingTemplate` directive is renamed to `igxExcelStyleSorting`.
- **Breaking Change** `igxExcelStyleMovingTemplate` directive is renamed to `igxExcelStyleMoving`.
- **Breaking Change** `igxExcelStyleHidingTemplate` directive is renamed to `igxExcelStyleHiding`.
- **Breaking Change** `onRowSelectionChange` event arguments are changed. The `row` property has been removed and the properties `added`, `removed` and `cancel` are newly added.
- **Breaking Change** `igxExcelStylePinningTemplate` directive is renamed to `igxExcelStylePinning`.
- **Breaking Change** `onRowDragEnd` and `onRowDragStart` event arguments are changed - `owner` now holds reference to the grid component instance, while `dragDirective` hold reference to the drag directive.
- `IgxCombo`
Expand All @@ -50,7 +55,7 @@ All notable changes for each version of this project will be documented in this
- For more information, visit the component's [readme](https://github.com/IgniteUI/igniteui-angular/tree/master/projects/igniteui-angular/src/lib/combo/README.md)

## 8.1.4
- `IgxDialog` new @Input `positionSettings` is now available. It provides the ability to get/set both position and animation settings of the Dialog component.
- `IgxDialog` new @Input `positionSettings` is now available. It provides the ability to get/set both position and animation settings of the Dialog component.

- `IgxDrag`
- Deprecated inputs - `hideBaseOnDrag`, `animateOnRelease`, `visible`.
Expand Down
153 changes: 146 additions & 7 deletions projects/igniteui-angular/src/lib/core/grid-selection.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Injectable, EventEmitter, NgZone } from '@angular/core';
import { IGridEditEventArgs } from '../grids/grid-base.component';


export interface GridSelectionRange {
rowStart: number;
rowEnd: number;
Expand Down Expand Up @@ -202,7 +201,7 @@ export class IgxGridCRUDService {

@Injectable()
export class IgxGridSelectionService {

grid;
dragMode = false;
activeElement: ISelectionNode | null;
keyboardState = {} as ISelectionKeyboardState;
Expand All @@ -213,7 +212,8 @@ export class IgxGridSelectionService {
temp = new Map<number, Set<number>>();
_ranges: Set<string> = new Set<string>();
_selectionRange: Range;

rowSelection: Set<any> = new Set<any>();
private allRowsSelected: boolean;

/**
* Returns the current selected ranges in the grid from both
Expand All @@ -227,7 +227,7 @@ export class IgxGridSelectionService {
const ranges = Array.from(this._ranges).map(range => JSON.parse(range));

// No ranges but we have a focused cell -> add it
if (!ranges.length && this.activeElement) {
if (!ranges.length && this.activeElement && this.grid.isCellSelectable) {
ranges.push(this.generateRange(this.activeElement));
}

Expand Down Expand Up @@ -304,7 +304,7 @@ export class IgxGridSelectionService {
}

selected(node: ISelectionNode): boolean {
return this.isActiveNode(node) || this.isInMap(node);
return (this.isActiveNode(node) && this.grid.isCellSelectable) || this.isInMap(node);
}

isActiveNode(node: ISelectionNode, mrl = false): boolean {
Expand Down Expand Up @@ -394,7 +394,6 @@ export class IgxGridSelectionService {
}

pointerDown(node: ISelectionNode, shift: boolean, ctrl: boolean): void {

this.addKeyboardRange();
this.initKeyboardState();
this.pointerState.ctrl = ctrl;
Expand Down Expand Up @@ -506,7 +505,8 @@ export class IgxGridSelectionService {
this.selectRange(node, state);
}

clear(): void {
clear(clearAcriveEl = false): void {
if (clearAcriveEl) { this.activeElement = null; }
this.selection.clear();
this.temp.clear();
this._ranges.clear();
Expand Down Expand Up @@ -541,6 +541,145 @@ export class IgxGridSelectionService {
range.collapse(true);
selection.addRange(range);
}

/** Returns array of the selected row id's. */
getSelectedRows(): Array<any> {
return this.rowSelection.size ? Array.from(this.rowSelection.keys()) : [];
}

/** Clears row selection, if filtering is applied clears only selected rows from filtered data. */
clearRowSelection(event?): void {
const removedRec = this.isFilteringApplied() ?
this.getRowIDs(this.allData).filter(rID => this.isRowSelected(rID)) : this.getSelectedRows();
const newSelection = this.isFilteringApplied() ? this.getSelectedRows().filter(x => !removedRec.includes(x)) : [];
this.emitRowSelectionEvent(newSelection, [], removedRec, event);
}

/** Select all rows, if filtering is applied select only from filtered data. */
selectAllRows(event?) {
const allRowIDs = this.getRowIDs(this.allData);
const addedRows = allRowIDs.filter((rID) => !this.isRowSelected(rID));
const newSelection = this.rowSelection.size ? allRowIDs.concat(this.getSelectedRows()) : addedRows;

this.emitRowSelectionEvent(newSelection, addedRows, [], event);
}

/** Select the specified row and emit event. */
selectRowById(rowID, clearPrevSelection?, event?): void {
if (!this.grid.isRowSelectable || this.isRowDeleted(rowID)) { return; }
clearPrevSelection = !this.grid.isMultiRowSelectionEnabled || clearPrevSelection;

const newSelection = clearPrevSelection ? [rowID] : this.getSelectedRows().indexOf(rowID) !== -1 ?
this.getSelectedRows() : [...this.getSelectedRows(), rowID];
const removed = clearPrevSelection ? this.getSelectedRows() : [];
this.emitRowSelectionEvent(newSelection, [rowID], removed, event);
}

/** Deselect the specified row and emit event. */
deselectRow(rowID, event?): void {
if (!this.isRowSelected(rowID)) { return; }
const newSelection = this.getSelectedRows().filter(r => r !== rowID);
if (this.rowSelection.size && this.rowSelection.has(rowID)) {
this.emitRowSelectionEvent(newSelection, [], [rowID], event);
}
}

/** Select specified rows. No event is emitted. */
selectRowsWithNoEvent(rowIDs: any[], clearPrevSelection?): void {
if (clearPrevSelection) { this.rowSelection.clear(); }
rowIDs.forEach(rowID => { this.rowSelection.add(rowID); });
this.allRowsSelected = undefined;
}

/** Deselect specified rows. No event is emitted. */
deselectRowsWithNoEvent(rowIDs: any[]): void {
rowIDs.forEach(rowID => this.rowSelection.delete(rowID));
this.allRowsSelected = undefined;
}

isRowSelected(rowID): boolean {
return this.rowSelection.size > 0 && this.rowSelection.has(rowID);
}

/** Select range from last selected row to the current specified row.*/
selectMultipleRows(rowID, rowData, event?): void {
this.allRowsSelected = undefined;
if (!this.rowSelection.size || this.isRowDeleted(rowID)) {
ChronosSF marked this conversation as resolved.
Show resolved Hide resolved
this.selectRowById(rowID);
return;
}
const gridData = this.allData;
const lastRowID = this.getSelectedRows()[this.rowSelection.size - 1];
const currIndex = gridData.indexOf(this.getRowDataById(lastRowID));
const newIndex = gridData.indexOf(rowData);
const rows = gridData.slice(Math.min(currIndex, newIndex), Math.max(currIndex, newIndex) + 1);

const added = this.getRowIDs(rows).filter(rID => !this.isRowSelected(rID));
const newSelection = this.getSelectedRows().concat(added);

this.emitRowSelectionEvent(newSelection, added, [], event);
}

areAllRowSelected(): boolean {
if (!this.grid.data) { return false; }
if (this.allRowsSelected !== undefined) { return this.allRowsSelected; }

const dataItemsID = this.getRowIDs(this.allData);
return this.allRowsSelected = Math.min(this.rowSelection.size, dataItemsID.length) > 0 &&
new Set(Array.from(this.rowSelection.values()).concat(dataItemsID)).size === this.rowSelection.size;
}

hasSomeRowSelected(): boolean {
const filteredData = this.isFilteringApplied() ?
this.getRowIDs(this.grid.filteredData).some(rID => this.isRowSelected(rID)) : true;
return this.rowSelection.size > 0 && filteredData && !this.areAllRowSelected();
}

public emitRowSelectionEvent(newSelection, added, removed, event?): boolean {
const currSelection = this.getSelectedRows();
if (this.areEqualCollections(currSelection, newSelection)) { return; }

const args = {
oldSelection: currSelection, newSelection: newSelection,
added: added, removed: removed, event: event, cancel: false
};
this.grid.onRowSelectionChange.emit(args);
if (args.cancel) { return; }
this.selectRowsWithNoEvent(args.newSelection, true);
}

public getRowDataById(rowID): Object {
if (!this.grid.primaryKey) { return rowID; }
ChronosSF marked this conversation as resolved.
Show resolved Hide resolved
const rowIndex = this.getRowIDs(this.grid.gridAPI.get_all_data(true)).indexOf(rowID);
return rowIndex < 0 ? {} : this.grid.gridAPI.get_all_data(true)[rowIndex];
}

public getRowIDs(data): Array<any> {
return this.grid.primaryKey && data.length ? data.map(rec => rec[this.grid.primaryKey]) : data;
}

public clearHeaderCBState(): void {
this.allRowsSelected = undefined;
}

/** Returns all data in the grid, with applied filtering and sorting and without deleted rows. */
public get allData(): Array<any> {
const allData = this.isFilteringApplied() || this.grid.sortingExpressions.length ?
this.grid.filteredSortedData : this.grid.gridAPI.get_all_data(true);
return allData.filter(rData => !this.isRowDeleted(this.grid.gridAPI.get_row_id(rData)));
}

private areEqualCollections(first, second): boolean {
return first.length === second.length && new Set(first.concat(second)).size === first.length;
}

private isFilteringApplied(): boolean {
return this.grid.filteringExpressionsTree.filteringOperands.length > 0;
}

private isRowDeleted(rowID): boolean {
return this.grid.gridAPI.row_deleted_transaction(rowID);
}
}

export function isChromium(): boolean {
Expand Down
24 changes: 9 additions & 15 deletions projects/igniteui-angular/src/lib/grids/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent & IGridDataBinda
this.grid.summaryService.clearSummaryCache(args);
this.updateData(this.grid, cell.id.rowID, data[index], cell.rowData, { [cell.column.field ]: args.newValue });
if (this.grid.primaryKey === cell.column.field) {
if (this.grid.selection.is_item_selected(this.grid.id, cell.id.rowID)) {
this.grid.selection.deselect_item(this.grid.id, cell.id.rowID);
this.grid.selection.select_item(this.grid.id, args.newValue);
if (this.grid.selectionService.isRowSelected(cell.id.rowID)) {
this.grid.selectionService.deselectRow(cell.id.rowID);
this.grid.selectionService.selectRowById(args.newValue);
}
if (this.grid.hasSummarizedColumns) {
this.grid.summaryService.removeSummaries(cell.id.rowID);
Expand Down Expand Up @@ -207,6 +207,7 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent & IGridDataBinda

update_row(row: IgxRow, value: any) {
const grid = this.grid;
const selected = grid.selectionService.isRowSelected(row.id);
const rowInEditMode = grid.crudService.row;
const data = this.get_all_data(grid.transactions.enabled);
const index = this.get_row_index_in_data(row.id);
Expand Down Expand Up @@ -245,10 +246,9 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent & IGridDataBinda

this.updateData(grid, row.id, data[index], args.oldValue, args.newValue);
const newId = grid.primaryKey ? args.newValue[grid.primaryKey] : args.newValue;
const selected = grid.selection.is_item_selected(grid.id, row.id);
if (selected) {
grid.selection.deselect_item(grid.id, row.id);
grid.selection.select_item(grid.id, newId);
grid.selectionService.deselectRow(row.id);
grid.selectionService.selectRowById(newId);
}
if (hasSummarized) {
grid.summaryService.removeSummaries(newId);
Expand Down Expand Up @@ -503,14 +503,9 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent & IGridDataBinda
// TODO: should we emit this when cascadeOnDelete is true for each row?!?!
grid.onRowDeleted.emit({ data: data[index] });

// first deselect row then delete it
if (grid.rowSelectable && grid.selection.is_item_selected(grid.id, rowId)) {
grid.deselectRows([rowId]);
} else {
grid.checkHeaderCheckboxStatus();
}

this.deleteRowFromData(rowId, index);

grid.selectionService.isRowSelected(rowId) ? grid.selectionService.deselectRow(rowId) : grid.selectionService.clearHeaderCBState();
(grid as any)._pipeTrigger++;
grid.notifyChanges();
// Data needs to be recalculated if transactions are in place
Expand All @@ -523,8 +518,7 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent & IGridDataBinda
}

public get_row_id(rowData) {
const grid = this.grid;
return grid.primaryKey ? rowData[grid.primaryKey] : rowData;
return this.grid.primaryKey ? rowData[this.grid.primaryKey] : rowData;
}

public row_deleted_transaction(rowID: any): boolean {
Expand Down
Loading