App.component.ts
import { Component,ViewChild, OnInit } from '@angular/core';
import { data } from './datasource';
import { EditSettingsModel, GridComponent, ToolbarItems } from '@syncfusion/ej2-angular-grids';
@Component({
selector: 'app-container',
template: `<ejs-grid [dataSource]='data'#grid id='grid' [editSettings]='editSettings'[toolbar]='toolbar' (created)= Oncreated($event)' >
…
</ejs-grid>`
})
export class AppComponent implements OnInit {
…
ngOnInit(): void {
this.editSettings = { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Dialog'
}
this.toolbar = ['Add', 'Edit', 'Delete']
Oncreated(args){
this.groupsService.getGroups().subscribe(
data => {
this.dataSource = data;
(this.groupsGrid.dataSource as ResultGroup[]) = data;
this.groupsGrid.refresh();
}
}
}
|