Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
142620 | Feb 12,2019 02:15 PM UTC | Feb 22,2019 05:17 AM UTC | Angular - EJ 2 | 7 |
![]() |
Tags: Grid |
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'});
}
}
|
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.