[GridFeatures.cshtml]
<script type="text/javascript">
$(function () {
$("#Grid").ejGrid({
dataSource : ej.DataManager({
url : "/Grid/DataSource",
adaptor : "UrlAdaptor"
}),
//showSummary: true,
allowPaging:true,
allowSorting: true,
pageSettings: { pageSize: 10 },
columns : [
---------------------------------
]
});
});
</script>
|
[GridController.cs]
public ActionResult DataSource(DataManager dm)
{
IEnumerable DataSource = new NorthwindDataContext().OrdersViews.ToList();
DataResult result = new DataResult();
DataOperations operation = new DataOperations();
result.result = DataSource;
if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
{
result.result = operation.PerformSorting(result.result, dm.Sorted);
}
result.count = result.result.AsQueryable().Count();
if (dm.Skip > 0) // for paging
result.result = operation.PerformSkip(result.result, dm.Skip);
if (dm.Take > 0)
result.result = operation.PerformTake(result.result, dm.Take);
return Json(new { result = result.result, count = result.count }); }
|