Hi Edmund,
We can enable the CRUD operation for the hierarchy grid. We achieved your requirement by using the RemoteSaveAdaptor. We have to define the Update/Insert/Delete methods in Grid controller for CRUD operation.If we have unique filed in each table no need to use ForeignKeyField("EnrollmentID") in childgrid.
.Datasource(ds =>//CRUD operation for parent grid ds.Json((IEnumerable<object>)ViewBag.datasource).UpdateURL("Update").InsertURL("Insert").RemoveURL("Delete").Adaptor(AdaptorType.RemoteSaveAdaptor))
//CRUD operation for child grid child.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource2).UpdateURL("ChildUpdate").InsertURL("ChildInsert").RemoveURL("ChildDelete").Adaptor(AdaptorType.RemoteSaveAdaptor)) |
We have created a sample and the same can be downloaded from the following location:
Sample Link : http://www.syncfusion.com/downloads/support/directtrac/general/Grid1214439525.zip
Please refer below documentation link for creating the hierarchy grid.
OnlineLink: http://help.syncfusion.com/ug/aspnetmvc/index.html#!Documents/hierarchygrid.htm
Please refer below documentation link for how we can use Adaptors for grid.
Online Documentation Link: http://helpjs.syncfusion.com/js/grid/data-adaptors
Please let me know if you need any further assistance.
Regards,
Isuriya R
By default we have a property parentDetails to get the parent details from child Grid and parent Grid details can be get by using actionBegin or actionComplete events.
Please refer the below online documentations for actionBegin and actionComplete events, @(Html.EJ().Grid<EmployeeView>("HierarchyGrid") .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource).UpdateURL("Update").InsertURL("Insert").RemoveURL("Delete").Adaptor(AdaptorType.RemoteSaveAdaptor)) .EditSettings(edit => edit.AllowEditing(true).AllowAdding(true).AllowDeleting(true)) …. .Columns(col => { …. }) .ChildGrid(child => { child.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource2).UpdateURL("ChildUpdate").InsertURL("ChildInsert").RemoveURL("ChildDelete").Adaptor(AdaptorType.RemoteSaveAdaptor)) .QueryString("ID") .ForeignKeyField("EnrollmentID") .AllowPaging() …. .Columns(col => { …. }).ClientSideEvents(e => e.ActionBegin("BeforeEdit").ActionComplete("AfterEdit")); })) <script> function BeforeEdit(args) { if (args.requestType == "add") { var parentKeyFieldValue = this.model.parentDetails.parentKeyFieldValue, parentKeyField = this.model.parentDetails.parentKeyField alert(parentKeyField + " : " + parentKeyFieldValue) } } function AfterEdit(args) { if (args.requestType == "save") { var parentKeyFieldValue = this.model.parentDetails.parentKeyFieldValue, parentKeyField = this.model.parentDetails.parentKeyField alert(parentKeyField + " : " + parentKeyFieldValue) } }
ActionBegin: http://helpjs.syncfusion.com/js/api/ejgrid#events:actionbegin
ActionComplete: http://helpjs.syncfusion.com/js/api/ejgrid#events:actioncomplete
We have created a sample to show the parentKeyField and parentKeyValue in both events and attached in the following link,
http://www.syncfusion.com/downloads/support/forum/119939/ze/SampleDemo1187856870
Please refer the following example code and get back to us if you need any further assistance.
</script>
Please try the above sample and get back to us if you have any concerns.
Regards,
Sellappandi R
Regards,
Isuriya R
Please log on to our support website to check for further updates related to this query.
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
Please let us know if you require further assistance on this.
Regards,
Isuriya R