Skip to content

Commit a2605a0

Browse files
authored
Merge pull request #10846 from IgniteUI/sstoychev/reemit-events-master
feat(grid): reemiting changing/ed events #10780 - master
2 parents 14fb58f + b3b9826 commit a2605a0

File tree

6 files changed

+45
-4
lines changed

6 files changed

+45
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ All notable changes for each version of this project will be documented in this
2626
<igx-column field="Age"></igx-column>
2727
</igx-grid>
2828
```
29+
- Exposed `dataChanging` and `dataChanged` events for the three grids that are re-emits of the corresponding `IgxForOf` events. These indicate the beginning and end of the input change triggering the actual data re-rendering which happens each time the data view changes. This happens after changes in either the data the grid is bound or the state affecting the operations which alter this data (e.g. sorting, filtering, group-by).
2930
- Scrolling with the mouse wheel over cells with templates that include scrollable containers now correctly scroll these inner containers before the grid body scrolls.
3031

3132
## 13.0.5

projects/igniteui-angular/src/lib/grids/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ A list of the events emitted by the **igx-grid**:
224224
|`rowEdit`|Emitted just before a row in edit mode's value is committed (e.g. by clicking the Done button on the Row Editing Overlay).|
225225
|`rowEditDone`|Emitted after exiting edit mode for a row and editing has been committed.|
226226
|`rowEditExit`|Emitted when a row exits edit mode without committing its values (e.g. by clicking the Cancel button on the Row Editing Overlay).|
227+
|`dataChanging`|Emitted before the grid's data view is changed because of a data operation, rebinding, etc.|
228+
|`dataChanged`|Emitted after the grid's data view is changed because of a data operation, rebinding, etc.|
227229
|`cellClick`|Emitted when a cell is clicked. Returns the cell object.|
228230
|`columnMoving`|Emitted when a column is moved. Returns the source and target columns objects. This event is cancelable.|
229231
|`columnMovingEnd`|Emitted when a column moving ends. Returns the source and target columns objects. This event is cancelable.|

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import { cloneArray, mergeObjects, compareMaps, resolveNestedPath, isObject, Pla
4141
import { GridColumnDataType } from '../data-operations/data-util';
4242
import { FilteringLogic, IFilteringExpression } from '../data-operations/filtering-expression.interface';
4343
import { IGroupByRecord } from '../data-operations/groupby-record.interface';
44-
import { IgxGridForOfDirective } from '../directives/for-of/for_of.directive';
44+
import { IForOfDataChangingEventArgs, IgxGridForOfDirective } from '../directives/for-of/for_of.directive';
4545
import { IgxTextHighlightDirective } from '../directives/text-highlight/text-highlight.directive';
4646
import { ISummaryExpression } from './summaries/grid-summary';
4747
import { RowEditPositionStrategy, IPinningConfig } from './grid.common';
@@ -1060,6 +1060,29 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
10601060
@Output()
10611061
public localeChange = new EventEmitter<boolean>();
10621062

1063+
/**
1064+
* Emitted before the grid's data view is changed because of a data operation, rebinding, etc.
1065+
*
1066+
* @example
1067+
* ```typescript
1068+
* <igx-grid #grid [data]="localData" [autoGenerate]="true" (dataChanging)='handleDataChangingEvent()'></igx-grid>
1069+
* ```
1070+
*/
1071+
@Output()
1072+
public dataChanging = new EventEmitter<IForOfDataChangingEventArgs>();
1073+
1074+
/**
1075+
* Emitted after the grid's data view is changed because of a data operation, rebinding, etc.
1076+
*
1077+
* @example
1078+
* ```typescript
1079+
* <igx-grid #grid [data]="localData" [autoGenerate]="true" (dataChanged)='handleDataChangedEvent()'></igx-grid>
1080+
* ```
1081+
*/
1082+
@Output()
1083+
public dataChanged = new EventEmitter<any>();
1084+
1085+
10631086
/**
10641087
* @hidden @internal
10651088
*/
@@ -3387,6 +3410,20 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
33873410
}
33883411
}
33893412

3413+
/**
3414+
* @hidden @internal
3415+
*/
3416+
public dataRebinding(event: IForOfDataChangingEventArgs) {
3417+
this.dataChanging.emit(event);
3418+
}
3419+
3420+
/**
3421+
* @hidden @internal
3422+
*/
3423+
public dataRebound(event) {
3424+
this.dataChanged.emit(event);
3425+
}
3426+
33903427
/** @hidden @internal */
33913428
public createFilterDropdown(column: ColumnType, options: OverlaySettings) {
33923429
options.outlet = this.outlet;

projects/igniteui-angular/src/lib/grids/grid/grid.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
[igxForContainerSize]='calcHeight'
8282
[igxForItemSize]="hasColumnLayouts ? rowHeight * multiRowLayoutRowSize + 1 : renderedRowHeight"
8383
[igxForTrackBy]='trackChanges'
84-
#verticalScrollContainer (chunkPreload)="dataLoading($event)">
84+
#verticalScrollContainer (chunkPreload)="dataLoading($event)" (dataChanging)="dataRebinding($event)" (dataChanged)="dataRebound($event)">
8585
<ng-template
8686
[igxTemplateOutlet]='getRowTemplate(rowData)'
8787
[igxTemplateOutletContext]='getContext(rowData, rowIndex)'

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
| gridRowPinning:id:false:pipeTrigger"
5959
[igxForScrollOrientation]="'vertical'" [igxForScrollContainer]='verticalScroll'
6060
[igxForContainerSize]='calcHeight' [igxForItemSize]="renderedRowHeight" [igxForTrackBy]='trackChanges'
61-
#verticalScrollContainer (chunkPreload)="dataLoading($event)">
61+
#verticalScrollContainer (chunkPreload)="dataLoading($event)" (dataChanging)="dataRebinding($event)" (dataChanged)="dataRebound($event)">
6262
<ng-template
6363
[igxTemplateOutlet]='(isHierarchicalRecord(rowData) ? hierarchical_record_template : (isChildGridRecord(rowData) ? child_record_template : hierarchical_record_template))'
6464
[igxTemplateOutletContext]='getContext(rowData, rowIndex, false)' (viewCreated)='viewCreatedHandler($event)'

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
| treeGridAddRow:false:pipeTrigger
6262
| gridRowPinning:id:false:pipeTrigger"
6363
let-rowIndex="index" [igxForScrollOrientation]="'vertical'" [igxForScrollContainer]='verticalScroll'
64-
[igxForContainerSize]='calcHeight' [igxForItemSize]="renderedRowHeight" #verticalScrollContainer>
64+
[igxForContainerSize]='calcHeight' [igxForItemSize]="renderedRowHeight" #verticalScrollContainer
65+
(dataChanging)="dataRebinding($event)" (dataChanged)="dataRebound($event)">
6566
<ng-template [igxTemplateOutlet]='isSummaryRow(rowData) ? summary_template : record_template'
6667
[igxTemplateOutletContext]='getContext(rowData, rowIndex, false)'
6768
(cachedViewLoaded)='cachedViewLoaded($event)'>

0 commit comments

Comments
 (0)