|
skip |
skip for sending the starting index of data |
|
take |
Take for sending ending index of data |
|
sortBy |
sortBy for sending for sort order details |
|
search |
Search for send search key |
|
where |
Where send the table name |
|
group |
Group sent the group details |
|
result |
Processed data |
|
count |
Return data count |
|
@Html.EJS().Grid("Grid").DataSource(dataManger => { dataManger.Url("/Home/UrlDatasource").Adaptor("UrlAdaptor"); }).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("120").ValidationRules(new { required = true }).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
).Render()
|
|
public ActionResult UrlDatasource(Data dm)
{
var order = OrdersDetails.GetAllRecords();
var Data = order.ToList();
int count = order.Count();
if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
{
switch (dm.Sorted[0].Name)
{
case "OrderID":
if (dm.Sorted[0].Direction == "ascending")
Data = Data.OrderBy(x => x.OrderID).ToList();
else
Data = Data.OrderByDescending(x => x.OrderID).ToList();
break;
case "CustomerID":
if (dm.Sorted[0].Direction == "ascending")
Data = Data.OrderBy(x => x.CustomerID).ToList();
else
Data = Data.OrderByDescending(x => x.CustomerID).ToList();
break;
case "ShipCountry":
if (dm.Sorted[0].Direction == "ascending")
Data = Data.OrderBy(x => x.ShipCountry).ToList();
else
Data = Data.OrderByDescending(x => x.ShipCountry).ToList();
break;
}
}
return dm.requiresCounts ? Json(new { result = Data.Skip(dm.skip).Take(dm.take), count = count }) : Json(Data); //skip and take will return the particular count of data
} |