Skip to content

Commit

Permalink
Merge pull request #10862 from IgniteUI/sstoychev/reemit-events-111
Browse files Browse the repository at this point in the history
feat(grid): reemiting changing/ed events #10780 - 11.1
  • Loading branch information
ChronosSF committed Jan 24, 2022
2 parents 67f9995 + 9d2a66c commit 4761189
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
2 changes: 2 additions & 0 deletions projects/igniteui-angular/src/lib/grids/README.md
Expand Up @@ -229,6 +229,8 @@ A list of the events emitted by the **igx-grid**:
|`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).|
|`rowEditDone`|Emitted after exiting edit mode for a row and editing has been committed.|
|`rowEditExit`|Emitted when a row exits edit mode without committing its values (e.g. by clicking the Cancel button on the Row Editing Overlay).|
|`dataChanging`|Emitted before the grid's data view is changed because of a data operation, rebinding, etc.|
|`dataChanged`|Emitted after the grid's data view is changed because of a data operation, rebinding, etc.|
|`onCellClick`|Emitted when a cell is clicked. Returns the cell object.|
|`onColumnMoving`|Emitted when a column is moved. Returns the source and target columns objects. This event is cancelable.|
|`onColumnMovingEnd`|Emitted when a column moving ends. Returns the source and target columns objects. This event is cancelable.|
Expand Down
38 changes: 37 additions & 1 deletion projects/igniteui-angular/src/lib/grids/grid-base.directive.ts
Expand Up @@ -38,7 +38,7 @@ import { DataType } from '../data-operations/data-util';
import { FilteringLogic, IFilteringExpression } from '../data-operations/filtering-expression.interface';
import { IGroupByRecord } from '../data-operations/groupby-record.interface';
import { ISortingExpression, SortingDirection } from '../data-operations/sorting-expression.interface';
import { IgxGridForOfDirective } from '../directives/for-of/for_of.directive';
import { IForOfDataChangingEventArgs, IgxGridForOfDirective } from '../directives/for-of/for_of.directive';
import { IgxTextHighlightDirective } from '../directives/text-highlight/text-highlight.directive';
import {
AbsoluteScrollStrategy,
Expand Down Expand Up @@ -936,6 +936,28 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
@Output()
public localeChange = new EventEmitter<boolean>();

/**
* Emitted before the grid's data view is changed because of a data operation, rebinding, etc.
*
* @example
* ```typescript
* <igx-grid #grid [data]="localData" [autoGenerate]="true" (dataChanging)='handleDataChangingEvent()'></igx-grid>
* ```
*/
@Output()
public dataChanging = new EventEmitter<IForOfDataChangingEventArgs>();

/**
* Emitted after the grid's data view is changed because of a data operation, rebinding, etc.
*
* @example
* ```typescript
* <igx-grid #grid [data]="localData" [autoGenerate]="true" (dataChanged)='handleDataChangedEvent()'></igx-grid>
* ```
*/
@Output()
public dataChanged = new EventEmitter<any>();

/**
* @hidden @internal
*/
Expand Down Expand Up @@ -3537,6 +3559,20 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
}
}

/**
* @hidden @internal
*/
public dataRebinding(event: IForOfDataChangingEventArgs) {
this.dataChanging.emit(event);
}

/**
* @hidden @internal
*/
public dataRebound(event) {
this.dataChanged.emit(event);
}

/**
* @hidden
* @internal
Expand Down
Expand Up @@ -144,7 +144,7 @@
[igxForContainerSize]='calcHeight'
[igxForItemSize]="hasColumnLayouts ? rowHeight * multiRowLayoutRowSize + 1 : renderedRowHeight"
[igxForTrackBy]='trackChanges'
#verticalScrollContainer (onChunkPreload)="dataLoading($event)">
#verticalScrollContainer (onChunkPreload)="dataLoading($event)" (onDataChanging)="dataRebinding($event)" (onDataChanged)="dataRebound($event)">
<ng-template
[igxTemplateOutlet]='getRowTemplate(rowData)'
[igxTemplateOutletContext]='getContext(rowData, rowIndex)'
Expand Down
Expand Up @@ -132,7 +132,7 @@
| gridAddRow:false:pipeTrigger"
[igxForScrollOrientation]="'vertical'" [igxForScrollContainer]='verticalScroll'
[igxForContainerSize]='calcHeight' [igxForItemSize]="renderedRowHeight" [igxForTrackBy]='trackChanges'
#verticalScrollContainer (onChunkPreload)="dataLoading($event)">
#verticalScrollContainer (onChunkPreload)="dataLoading($event)" (onDataChanging)="dataRebinding($event)" (onDataChanged)="dataRebound($event)">
<ng-template
[igxTemplateOutlet]='(isHierarchicalRecord(rowData) ? hierarchical_record_template : (isChildGridRecord(rowData) ? child_record_template : hierarchical_record_template))'
[igxTemplateOutletContext]='getContext(rowData, rowIndex, false)' (onViewCreated)='viewCreatedHandler($event)'
Expand Down
Expand Up @@ -110,7 +110,8 @@
| gridRowPinning:id:false:pipeTrigger
| gridAddRow:false:pipeTrigger"
let-rowIndex="index" [igxForScrollOrientation]="'vertical'" [igxForScrollContainer]='verticalScroll'
[igxForContainerSize]='calcHeight' [igxForItemSize]="renderedRowHeight" #verticalScrollContainer>
[igxForContainerSize]='calcHeight' [igxForItemSize]="renderedRowHeight" #verticalScrollContainer
(onDataChanging)="dataRebinding($event)" (onDataChanged)="dataRebound($event)">
<ng-template [igxTemplateOutlet]='isSummaryRow(rowData) ? summary_template : record_template'
[igxTemplateOutletContext]='getContext(rowData, rowIndex, false)'
(onCachedViewLoaded)='cachedViewLoaded($event)'>
Expand Down

0 comments on commit 4761189

Please sign in to comment.