|
[App.component.html]
<div class="control-section">
<ejs-grid #grid [dataSource]='data | async' allowPaging= 'true' [pageSettings]='pageOptions' allowSorting= 'true' (dataStateChange)= 'dataStateChange($event)'
(dataBound)='dataBound($event)' >
<e-columns>
<e-column field= "OrderID" headerText="Order ID" width="130" ></e-column>
<e-column field= "CustomerID" headerText="Customer Name" width="150"></e-column>
<e-column field= "ShipName" headerText="Ship Name" width="200"></e-column>
<e-column field= "ShipCity" headerText="Ship City" width="150"></e-column>
</e-columns>
</ejs-grid>
</div>` |
|
[App.component.ts]
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
provider:[OrdersService]
})
export class AppComponent {
public data: Observable<DataStateChangeEventArgs>;
public pageOptions: Object;
@ViewChild('grid')
public grid: GridComponent;
public state: DataStateChangeEventArgs;
constructor( private service: OrdersService) {
this.data = service;
}
public dataStateChange(state: DataStateChangeEventArgs): void {
this.service.execute(state);
}
public dataBound () {
// here we are selecting the row after the refresh Complete
this.grid.selectRow(0);
}
public ngOnInit(): void {
this.pageOptions = { pageSize: 10, pageCount: 4 };
let state = { skip: 0, take: 10 };
this.service.execute(state);
}
} |