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.
Unfortunately, activation email could not send to your email. Please try again.

Create Hierarch Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

119939 Aug 17,2015 07:29 AM Aug 27,2015 09:06 AM ASP.NET MVC 14
loading
Tags: Grid
Edmund Herbert
Asked On August 17, 2015 07:29 AM


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

Isuriya Rajan [Syncfusion]
Replied On August 18, 2015 01:24 PM

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



Edmund Herbert
Replied On August 19, 2015 04:01 AM

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




Sellappandi Ramu [Syncfusion]
Replied On August 20, 2015 08:16 AM

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

Edmund Herbert
Replied On August 20, 2015 10:42 AM

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





Isuriya Rajan [Syncfusion]
Replied On August 21, 2015 08:49 AM

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

Edmund Herbert
Replied On August 21, 2015 09:11 AM

Thank you very much

Regards

Edmund Herbert

Isuriya Rajan [Syncfusion]
Replied On August 24, 2015 07:10 AM

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

Regards,

Isuriya R      


Isuriya Rajan [Syncfusion]
Replied On August 26, 2015 07:06 AM

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    


Edmund Herbert
Replied On August 26, 2015 07:16 AM

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

Regards

Edmund Herbert

Edmund Herbert
Replied On August 26, 2015 07:21 AM


Edmund Herbert
Replied On August 26, 2015 07:36 AM

Hi I can't find it

Regards

Edmund Herbert

K Kalai Selvi [Syncfusion]
Replied On August 27, 2015 08:35 AM

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

Edmund Herbert
Replied On August 27, 2015 08:38 AM

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

Thank You

Regards

Edmund Herbert

Sellappandi Ramu [Syncfusion]
Replied On August 27, 2015 09:06 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;