<ej-grid id="ParentGrid" allow-filtering="true" allow-paging="true" row-selected="onRowSelect" selected-row-index="0"> <e-datamanager json="(IEnumerable<object>)ViewBag.parent" /> .. .. </ej-grid> <ej-grid id="ChildGrid" allow-filtering="true" allow-paging="true"> . . . </ej-grid> <script> var json = @Html.Raw(Json.Serialize(ViewBag.child)); function onRowSelect(args) { var gridObj = $("#ChildGrid").ejGrid("instance"); var value = args.data.EmployeeID; var detaildata = ej.DataManager(json).executeLocal(ej.Query().where("EmployeeID", "equal", value); gridObj.dataSource(detaildata); } </script> |
Hi Urs,
In the row-Selected event of the Master Grid, you have to call the dataSource method of the child Grid to update them. Refer to the following code example and Help Documents for Asp.Net Core.
<ej-grid id="ParentGrid" allow-filtering="true" allow-paging="true" row-selected="onRowSelect" selected-row-index="0"><e-datamanager json="(IEnumerable<object>)ViewBag.parent" />....</ej-grid><ej-grid id="ChildGrid" allow-filtering="true" allow-paging="true">. . .</ej-grid><script>var json = @Html.Raw(Json.Serialize(ViewBag.child));function onRowSelect(args) {var gridObj = $("#ChildGrid").ejGrid("instance");var value = args.data.EmployeeID;var detaildata = ej.DataManager(json).executeLocal(ej.Query().where("EmployeeID", "equal", value);gridObj.dataSource(detaildata);}</script>
DataSource method: https://help.syncfusion.com/api/js/ejgrid#methods:datasource
We have prepared a sample that can be downloaded from the following location.
Sample: http://www.syncfusion.com/downloads/support/forum/126952/ze/ASPCore_MasterDetailGrid22983396.zip
Regards,Seeni Sakthi Kumar S.
<ej-grid id="ParentGrid" allow-filtering="true" allow-paging="true" template-refresh="refresh" row-selected="onRowSelect" selected-row-index="0">
<e-datamanager json="(IEnumerable<object>)ViewBag.parent" />
..
..
</ej-grid>
<ej-grid id="ChildGrid" allow-filtering="true" allow-paging="true">
<e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" />
<e-toolbar-settings show-toolbar="true" toolbar-items='@new List<string> {"add","edit","update","cancel"}' />
<e-columns>
<e-column header-text="Order ID" is-primary-key="true" field="OrderID" />
<e-column header-text="Employee ID" field="EmployeeID" visible="false" />
.. .
.. .
</e-columns>
</ej-grid>
<script>
var json = @Html.Raw(Json.Serialize(ViewBag.child));
function onRowSelect(args) {
var gridObj = $("#ChildGrid").ejGrid("instance");
var value = args.data.EmployeeID;
var detaildata = ej.DataManager(json).executeLocal(ej.Query().where("EmployeeID", "equal", value));
var dataMgr = ej.DataManager({
json: detaildata,
updateUrl: "/Home/CellEditUpdate",
insertUrl: "/Home/CellEditInsert",
removeUrl: "/Home/CellEditDelete",
adaptor: "remoteSaveAdaptor"
})
gridObj.dataSource(dataMgr);
}
</script> |
<ej-grid id="ParentGrid" allow-paging="true" row-selected="onRowSelect" > <e-datamanager json="(IEnumerable<object>)ViewBag.parent" /> . .. .. . </e-columns> </ej-grid> <ej-grid id="ChildGrid" allow-paging="true" > <e-datamanager adaptor="remoteSaveAdaptor" /> </ej-grid> <script> var json = @Html.Raw(Json.Serialize(ViewBag.child)); function onRowSelect(args) { var gridObj = $("#ChildGrid").ejGrid("instance"); var value = args.data.EmployeeID; var detaildata = ej.DataManager(json).executeLocal(ej.Query().where("EmployeeID", "equal", value)); var dataMgr = ej.DataManager({ json: detaildata, updateUrl: "/Home/CellEditUpdate", insertUrl: "/Home/CellEditInsert", removeUrl: "/Home/CellEditDelete", adaptor: "remoteSaveAdaptor" }) gridObj.dataSource(dataMgr); } |
<ej-grid id="ParentGrid" allow-paging="true" row-selected="onRowSelect" > . . . . . </ej-grid> <ej-grid id="ChildGrid" allow-paging="true" > <e-datamanager adaptor="remoteSaveAdaptor" /> <e-columns> <e-column header-text="Order ID" is-primary-key="true" field="OrderID" /> <e-column header-text="Employee ID" field="EmployeeID" visible="false" /> . . . </e-columns> </ej-grid> <script> var json = @Html.Raw(Json.Serialize(ViewBag.child)); function onRowSelect(args) { var gridObj = $("#ChildGrid").ejGrid("instance"); var value = args.data.EmployeeID; var detaildata = ej.DataManager(json).executeLocal(ej.Query().where("EmployeeID", "equal", value)); var dataMgr = ej.DataManager({ json: detaildata, updateUrl: "/Home/CellEditUpdate", insertUrl: "/Home/CellEditInsert", removeUrl: "/Home/CellEditDelete", adaptor: "remoteSaveAdaptor" }) gridObj.model.columns[1].defaultValue = args.data.EmployeeID; gridObj.dataSource(dataMgr); } </script> |
<ej-grid id="ParentGrid" allow-paging="true" row-selected="onRowSelect" > <e-datamanager json="(IEnumerable<object>)ViewBag.parent" update-url="/Home/EditUpdate" insert-url="/Home/EditInsert" remove-url="/Home/EditDelete" adaptor="remoteSaveAdaptor" /> . . </ej-grid> <ej-grid id="ChildGrid" allow-paging="true" action-complete="onDataBound" > <e-datamanager adaptor="remoteSaveAdaptor" /> .. . </ej-grid> <script> var json = @Html.Raw(Json.Serialize(ViewBag.child)); function onRowSelect(args) { var gridObj = $("#ChildGrid").ejGrid("instance"); .. . gridObj.model.columns[1].defaultValue = args.data.EmployeeID; gridObj.dataSource(dataMgr); } var flag = true; function onDataBound(args){ if(this.initialRender && flag){ flag = false; var gridObj = $("#ParentGrid").ejGrid("instance"); gridObj.selectRows(0); } } </script> |
<ej-grid id="ParentGrid" allow-paging="true" row-selected="onRowSelect"> <e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" /> <e-toolbar-settings show-toolbar="true" toolbar-items='@new List<string> {"add","edit","update","cancel"}' /> <e-datamanager json="(IEnumerable<object>)ViewBag.parent" update-url="/Home/EditUpdate" insert-url="/Home/EditInsert" remove-url="/Home/EditDelete" adaptor="remoteSaveAdaptor" /> </ej-grid> <ej-grid id="ChildGrid" allow-paging="true" action-complete="onDataBound"> <e-datamanager adaptor="remoteSaveAdaptor" /> <e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" /> <e-toolbar-settings show-toolbar="true" toolbar-items='@new List<string> {"add","edit","update","cancel"}' /> . .. .. </ej-grid> <script> function onRowSelect(args) { var gridObj = $("#ChildGrid").ejGrid("instance"); var value = args.data.EmployeeID; var dataManager = ej.DataManager({ url: "/Home/Data", adaptor: new ej.UrlAdaptor() }); var query = ej.Query().where("EmployeeID", "equal", value); gridObj.element.ejWaitingPopup("show");//show the popup var execute = dataManager.executeQuery(query) // executing query .done(function (e) { var dataMgr = ej.DataManager({ json: e.result.result, updateUrl: "/Home/CellEditUpdate", insertUrl: "/Home/CellEditInsert", removeUrl: "/Home/CellEditDelete", adaptor: "remoteSaveAdaptor" }) gridObj.element.ejWaitingPopup("hide");//hide the popup gridObj.model.columns[1].defaultValue = args.data.EmployeeID; gridObj.dataSource(dataMgr); }); } var flag = true; function onDataBound(args){ if(this.initialRender && flag){ flag = false; var gridObj = $("#ParentGrid").ejGrid("instance"); gridObj.selectRows(0); } } </script> public ActionResult Data([FromBody]DataManager value) { IEnumerable Data = order; DataOperations dp = new DataOperations(); if (value.Where != null) { Data = dp.PerformWhereFilter(Data, value.Where, value.Where[0].Condition); } return Json(new { result = Data }); } |