<ejs-grid #grid [dataSource]='data' allowGrouping="true" allowFiltering="true" allowPaging="true" allowSorting="true" height="320">
<e-columns>
<e-column field='OrderID' headerText='Order ID' isPrimaryKey=true width='150'></e-column>
<e-column field='CustomerID' headerText='Customer Name' width='150'></e-column>
<e-column field='ShipCity' headerText='ShipCity' width='150' textAlign='Right'></e-column>
</e-columns>
</ejs-grid> |
ngOnInit(): void {
this.data = new DataManager({
url: 'Home/UrlDatasource',
adaptor: new UrlAdaptor
});
} |
public IActionResult UrlDatasource([FromBody]DataManagerRequest dm)
{
IEnumerable DataSource = OrdersDetails.GetAllRecords();
DataOperations operation = new DataOperations();
. . . . .
int count = DataSource.Cast<OrdersDetails>().Count(); // Total Count of the Grid DataSource
if (dm.Skip != 0)
{
DataSource = operation.PerformSkip(DataSource, dm.Skip); //Paging
}
if (dm.Take != 0)
{
DataSource = operation.PerformTake(DataSource, dm.Take);
}
return dm.RequiresCounts ? Json(new { result = DataSource, count = count}) : Json(DataSource);
}
|