<div id="Grid"></div>
<script type="text/javascript">
$(function () {
var gridData = @Html.Raw(Json.Encode(Model));
var dataManger = ej.DataManager({
url: "/Home/DataSource",
adaptor: new ej.UrlAdaptor()
});
$("#Grid").ejGrid({
dataSource: gridData,
.. .
. . .
childGrid: {
dataSource: dataManger,
allowPaging: true,
pageSettings: {
pageSize: 5
},
queryString: "EmployeeID",
.. .
. ..
},
});
});
</script>
@{Html.EJ().Grid<object>("HierarchyGrid")
.Columns(col =>
{
col.Field("EmployeeID").IsPrimaryKey(true).Add();
})
.ChildGrid(child =>
{
.QueryString("EmployeeID")
.Datasource(ds => ds.URL("/Home/DataSource").Adaptor(AdaptorType.UrlAdaptor))
. .
. .
}).Render();
}
public ActionResult DataSource(Syncfusion.JavaScript.DataManager dm)
{
IEnumerable datasource = new NorthwindDataContext().OrdersViews.ToList();
DataOperations operation = new DataOperations();
if (dm.Where != null)
{
datasource = operation.PerformWhereFilter(datasource, dm.Where, dm.Where[0].Condition);
}
int count = datasource.AsQueryable().Count(); ;
if (dm.Skip >= 0)//for paging
datasource = operation.PerformSkip(datasource, dm.Skip);
if (dm.Take > 0)//for paging
datasource = operation.PerformTake(datasource, dm.Take);
return Json(new { result = datasource, count = count }, JsonRequestBehavior.AllowGet);
} |