- Home
- Forum
- ASP.NET MVC
- Create Hierarch Grid
Create Hierarch Grid
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
Thank you for example could I explain what I am trying to do
One to many Order can have many OrderDetails
Using Hierarch Grid i need the Orders to create index for database (no manual entry)
The same goes for the OrderDetails the OrderDetailsId is created automatically user does not see id (No manual selection of orderid)
I want to be able to add any number of OrderDetails to Order and to be able to edit order or Orderdetail
When OrderDetail record is added it must obtain OrderId to create join to Order table
Thanks
Edmund
Thanks for the update.
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
Thanks for your help, I need you to show me an example as follows:
- Table Order = OrderId , Name
- Table OrderDetail = OrderDetailId Description
- In Hierarchy Grid I need following:
- Order Record I must be in Main Grid with no OrderId (this is auto generated)
- The child grid is the orderdetail table also with no OrderDetailId visible (this is auto generated)
- one Order record to many Orderdetail Records
- I must be able to add many OrderDetail records to child grid
When I have added a child record and the json is returned the grid must auto update (refresh grid) to show added child record
I know I am being a pain
but please bear with me
Again thanks for all the hard work I appreciate it
Regards
Edmund Herbert
We considered your requirement as a custom sample and we will update you the sample on 26th August 2015(Two business days).
Please find the following information for the custom sample.
As a parent grid, we rendered the hierarchy grid by order table and order Details as a child Grid. In both table primary keys are auto incremented by one and these two columns in invisible state.
Please let us know if you have any concern.
Regards,
Isuriya R
Thanks for your patience.
Please let us know if you require further assistance on this.
Regards,
Isuriya R
We have created new incident “#143261” for the your custom sample and related queries and please follow up the incident “#143261” for better follow up
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
Regards
Edmund Herbert
on
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
Regards
Edmund Herbert
Could you please try again to login to our support website?
Regards,
Kalaiselvi
Thank You
Regards
Edmund Herbert
Thanks for the update.
Please get back to us if you have any queries. We are happy to assist you.
Regards,
Sellappandi R
- 14 Replies
- 4 Participants
-
EH Edmund Herbert
- Aug 17, 2015 11:29 AM UTC
- Aug 27, 2015 01:06 PM UTC