[HttpGet]
public object Get()
{
var dataSource = _context.Orders.Take(100).ToList();
var queryString = Request.Query;
int skip = Convert.ToInt32(queryString["$skip"]);
int take = Convert.ToInt32(queryString["$top"]);
string sort = queryString["$orderby"];//sorting
string filter = queryString["$filter"];
if (sort != null) {
dataSource = dataSource.AsQueryable().OrderBy(sort).ToList();
}
. . .
. . .
var count = dataSource.Count;
return new { Items = dataSource.Skip(skip).Take(take), Count = dataSource.Count() };
}
<ej-grid id="Grid" allow-paging="true" allow-sorting="true" allow-filtering="true">
<e-datamanager url="/api/Orders" adaptor="WebApiAdaptor"></e-datamanager>
<e-columns>
<e-column field="OrderID" header-text="Order ID" is-primary-key="true" text-align="Right" width="75"></e-column>
<e-column field="CustomerID" header-text="Customer ID" width="80"></e-column>
<e-column field="EmployeeID" header-text="Employee ID" text-align="Left" width="75"></e-column>
</e-columns>
</ej-grid> |