import { DataManager } from '@syncfusion/ej2-data';
this.dataService.getEnergiasApi().subscribe(data => {
this.dsEnergiaApi = new DataManager(data);
});
|
<ejs-grid #gridClientesApi [dataSource]='dsClientesApi' [childGrid]='childGrid' (actionFailure)='actionFailure($event)' (created)='created($event)'
allowPaging='true' allowSorting='true' allowTextWrap='true' (dataBound)='dataBound($event)' allowResizing='true' allowFiltering='true' allowExcelExport='true'>
<e-columns>
<e-column field='id' headerText='id' isPrimaryKey='true'></e-column>
. . . . . . .
</e-columns>
</ejs-grid>
|
export class AppComponent implements OnInit {
constructor(private dataService: DataService) { }
ngAfterViewInit(){
this.dataService.getEnergiasApi().subscribe(data => {
this.dsEnergiaApi = new DataManager(data);
});
this.dataService.getClientesApi().subscribe(data => {
this.dsClientesApi = data;
this.grid.hideSpinner();
});
}
ngOnInit() {
this.childGrid = { dataSource: this.dsEnergiaApi, actionFailure: this.actionFailure, queryString: 'id', allowPaging: true, pageSettings: {pageSize: 6, pageCount: 5},
columns: [
{ field: 'cif', headerText: 'cif', textAlign: 'Right', width: 120 },
{ field: 'idEnergia', headerText: 'idEnergia', width: '120', foreignKeyValue: 'nombre', foreignKeyField: 'id' }
]
};
dataBound(args){
// bind datasource for child grid
this.grid.childGrid.dataSource = this.dsClientesApi;
this.grid.childGrid.columns[1].dataSource = this.dsEnergiaApi; // foreignkey datasource
}
created(args){
this.grid.showSpinner();
setSpinner({type: 'Bootstrap'});
}
}
|
<ejs-grid #gridClientesApi [dataSource]='dsClientesApi' [childGrid]='childGrid' (actionFailure)='actionFailure($event)' (created)='created($event)'
allowPaging='true' allowSorting='true' allowTextWrap='true' (dataBound)='dataBound($event)' allowResizing='true' allowFiltering='true' allowExcelExport='true'>
<e-columns>
<e-column field='id' headerText='id' isPrimaryKey='true'></e-column>
. . . . . . .
</e-columns>
</ejs-grid>
|
export class AppComponent implements OnInit {
constructor(private dataService: DataService) { }
ngAfterViewInit(){
this.dataService.getEnergiasApi().subscribe(data => {
this.dsEnergiaApi = new DataManager(data);
});
this.dataService.getClientesApi().subscribe(data => {
this.dsClientesApi = data;
// need to do this in ngAfterViewInit so that we can get the grid instance
this.grid.hideSpinner();
});
}
created(args){
this.grid.showSpinner();
setSpinner({type: 'Bootstrap'});
}
}
|