<ej-grid id="GridContainer"
allow-resize-to-fit="true"
allow-sorting="true"
allow-text-wrap="true"
allow-paging="true"
is-responsive="true"
enable-responsive-row="true">
<e-datamanager url="/Home/DataSource" insert-url="/Home/CellEditInsert" update-url="/Home/CellEditUpdate" remove-url="/Home/CellEditDelete" adaptor="UrlAdaptor"></e-datamanager>
..
<e-columns>
<e-column field="OrderID"
header-text="ID"
is-primary-key="true"
is-identity="true"
visible="false" />
<e-column field="CustomerID" header-text="CustomerID" />
<e-column field="EmployeeID" header-text="EmployeeID" />
</e-columns>
</ej-grid>
public ActionResult DataSource([FromBody]DataManager dm)
{
IEnumerable data = order;
DataOperations operation = new DataOperations();
if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
{
data = operation.PerformSorting(data, dm.Sorted);
}
if (dm.Where != null && dm.Where.Count > 0) //Filtering
{
data = operation.PerformWhereFilter(data, dm.Where, dm.Where[0].Operator);
}
int count = data.Cast<Orders>().Count();
if (dm.Skip != 0) //paging
{
data = operation.PerformSkip(data, dm.Skip);
}
if (dm.Take != 0)
{
data = operation.PerformTake(data, dm.Take);
}
return Json(new { result = data, count = count });
} |
The DataManager class helps in binding the Grid queries passed to the server-side. Based on those queries
you can perform server-side operation on the Grid data.
The query parameters that help you perform the server-side operations are as follows.
DataManager Operations:
The query parameters are serialized by the DataManager class and the server-side operations such as sorting, filtering, paging are performed by the PerformSorting, PerfomWherFilter, PerformSkip and PerformTake methods. |