We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Create Hierarch Grid


Hi Guys could you help me please I want to create a Product and Order grid as per your MVC Hierarchy Grid example I use Entity Framework Code first and local db and MVC 5

I was wondering if the child grid  could also do full CRUD features from say the order controller , I want the Product grid to display all the related chid Orders and be able to Create Read Update and Delete from the child Grid.

Also the Product Grid must also supply same services  (CRUD)

Is this possible and if so can you supply me with a sample 

Many thanks Edmund Herbert

14 Replies

IR Isuriya Rajan Syncfusion Team August 18, 2015 05:24 PM UTC

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




EH Edmund Herbert August 19, 2015 08:01 AM UTC

Hi Isuriya

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





SR Sellappandi Ramu Syncfusion Team August 20, 2015 12:16 PM UTC

Hi 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,

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.

@(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)

        }

    }
</script>


Please try the above sample and get back to us if you have any concerns.

Regards,
Sellappandi R


EH Edmund Herbert August 20, 2015 02:42 PM UTC

Hi Sellappandi,

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






IR Isuriya Rajan Syncfusion Team August 21, 2015 12:49 PM UTC

Hi Edmund,
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


EH Edmund Herbert August 21, 2015 01:11 PM UTC

Thank you very much

Regards

Edmund Herbert


IR Isuriya Rajan Syncfusion Team August 24, 2015 11:10 AM UTC

Hi Edmund ,
Thanks for your patience.
Please let us know if you require further assistance on this.

Regards,

Isuriya R      



IR Isuriya Rajan Syncfusion Team August 26, 2015 11:06 AM UTC

Hi Edmund,

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    



EH Edmund Herbert August 26, 2015 11:16 AM UTC

Hi are you still sending updated example on 2015/08/26

Regards

Edmund Herbert


EH Edmund Herbert August 26, 2015 11:21 AM UTC



EH Edmund Herbert August 26, 2015 11:36 AM UTC

Hi I can't find it

Regards

Edmund Herbert


KK K Kalai Selvi Syncfusion Team August 27, 2015 12:35 PM UTC

Hi Edmund,
 
Could you please try again to login to our support website?
 
Regards,
Kalaiselvi


EH Edmund Herbert August 27, 2015 12:38 PM UTC

Hi Guys, this is exactly what I was looking for.

Thank You

Regards

Edmund Herbert


SR Sellappandi Ramu Syncfusion Team August 27, 2015 01:06 PM UTC

Hi Edmund,

Thanks for the update.

Please get back to us if you have any queries. We are happy to assist you.

Regards,
Sellappandi R

Loader.
Up arrow icon