Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144377 | May 3,2019 05:51 AM UTC | May 7,2019 07:18 AM UTC | Angular - EJ 2 | 1 |
![]() |
Tags: Grid |
@Component({
selector: 'app-root',
template: '<button (click)="refresh($event)"> Refresh</button>
<ejs-grid #grid [dataSource]='data' allowSorting="true" [allowGrouping]="true" [groupSettings]="groupOptions"
(dataBound)='dataBound()' (actionBegin)="begin($event)" (actionComplete)="complete($event)" >
<e-columns>
. . .
</e-columns>
</ejs-grid>',
})
export class AppComponent {
. . .
ngOnInit(): void {
this.data = inventoryData.slice(0,10);
this.groupOptions = { showGroupedColumn: false, columns: ['Country'] };
}
dataBound() {
if(this.initial){
this.grid.groupModule.collapseAll();
this.initial = false;
}
}
begin(e){
if(e.requestType == 'refresh'){
// storing the expanded row index in a variable
let indexes: number[] = [];
let elements = this.grid.element.querySelectorAll('.e-recordplusexpand');
for (let i = 0; i < elements.length; i++) {
let tr = elements[i].closest('tr');
indexes.push((tr as HTMLTableRowElement).rowIndex);
}
this.state = indexes;
}
}
complete(e){
if(e.requestType == 'refresh'){
if (this.state.length) {
let elements = this.grid.getContentTable().querySelectorAll('tr');
for (let i = 0; i < elements.length; i++) {
let icon = elements[i].querySelector('.e-recordplusexpand');
if(icon && !this.state.filter(ele=>ele==i).length ){
(icon as any).click(); // collapse the row after refreshing
}
}
}else{
this.grid.groupModule.collapseAll();
}
}
}
refresh(e){
this.grid.refresh(); // refreshed the Grid manually
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.