<div id="Grid"></div>
<script>
$(function () {
$("#Grid").ejGrid({
dataSource: ej.DataManager({
url: "/Home/Datasource",
adaptor: new ej.UrlAdaptor()
}),
allowScrolling: true,
scrollSettings: { height: 500, allowVirtualScrolling: true, enableVirtualization: true },
. . .
});
})
</script>
public ActionResult Datasource(DataManager dm)
{
IEnumerable data = new NorthwindDataContext().OrdersViews.ToList();
DataOperations operation = new DataOperations();
int count = data.AsQueryable().Count();
if (dm.Skip != 0)
{
data = operation.PerformSkip(data, dm.Skip);
}
if (dm.Take != 0)
{
data = operation.PerformTake(data, dm.Take);
}
return Json(new { result = data, count = count }, JsonRequestBehavior.AllowGet);
} |