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
close icon

Trouble getting start with Hierarchy Grid

Hi, I'm trying to set up a Hierarchy Grid, using the examples of thread #114261, and the following url 
https://help.syncfusion.com/aspnetmvc-classic/grid/hierarchical-grid    and I have two errors on my controller, and I can't figure it out. 

        public ActionResult ChildGrid(PagingParams args, int? capacitacion_id)
            var data = capacitacion.getListadoParticipantes(capacitacion_id);
            return data.GridActions<GetCapacitacionParticipantesResult>();

The first thing is in the parameter PagingParams args, the error is "cs0246 the type or namespace name 'PagingParams' could not be found"

The second error is in the return  data.GridActions<GetCapacitacionParticipantesResult>(); the error is cs1061 'IEnumerable' does not contain a definition for GridActions.

So, how can I fix this, in order to use, the Hierarchy Grid

Best regards

4 Replies

IR Isuriya Rajan Syncfusion Team January 19, 2017 07:31 AM UTC

Hi Dayne, 
Thanks for contacting Syncfusion support, 
We have validated your mentioned issues and found the cause  .You have missed to refer the Syncfusion.Mvc.Grid namespace in your controller page.So we suggest to refer Syncfusion.Mvc.Grid namespace it will solve your mentioned issues. 

Please refer the below code example 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Mvc; 
using Syncfusion.Mvc.Grid; 
using ChildGridProperties.Models; 
using System.Collections; 

Please refer the below online sample link: 

If we misunderstood your query please get back to us. 

Isuriya R 

DA Dayne January 19, 2017 03:26 PM UTC

I can't refer the Syncfusion.Mvc.Grid namespace in my controller page, it doesn't appear as an option, check the image attached in the .rar file. Am I missing a reference?

Best regards

Attachment: Syncfusion_776dc24b.rar

DA Dayne January 19, 2017 10:14 PM UTC

So, I have missing the nuget package Syncfusion.AspNet.Mvc4.Classic, I only had installed the package Syncfusion.AspNet.Mvc4, so now I can add the reference properly. 

But, by using this syntax Html.Syncfusion().Grid() to build the Grid, I don´t have the option to Filter like Excel as I do using the syntax Html.EJ().Grid(), so I discard the solution provided by the link http://mvc.syncfusion.com/demos/ui/grid/Hierarchy/ServersideHierarchy, instead I use the example provided in the following URL https://www.syncfusion.com/kb/6316/how-to-pass-parentkey-from-parent-to-childgrid, but this example does not provide the controller code, and the child data does not load properly, so I give ypu my code.

        .Columns(col =>
                child =>
                         .FilterSettings(filter => { filter.FilterType(FilterType.Excel); })
                         .Columns(col =>
                             col.Field(p => p.FullName).HeaderText("Empleado").Width(35).TextAlign(Syncfusion.JavaScript.TextAlign.Right).Add();
                             col.Field(p => p.Empresa).HeaderText("Empresa").Width(35).TextAlign(Syncfusion.JavaScript.TextAlign.Right).Add();
                             col.Field(p => p.Dpto).HeaderText("Departamento").Width(35).TextAlign(Syncfusion.JavaScript.TextAlign.Right).Add();
                       .ClientSideEvents(eve => { eve.Load("loadEvent"); })


Javascript for the child grid

<script type="text/javascript">
    function loadEvent(args) {
        var data = this.model.parentDetails.parentKeyFieldValue;
        this.model.dataSource = ej.DataManager({ url: "/CapitalHumano/GetParticipantes?capacitacion_id=" + data + "", adaptor: "UrlAdaptor" });

Controller  function GetParticipantes, wich populate the child grid

 public ActionResult GetParticipantes(int? capacitacion_id)
            IEnumerable data = capacitacion.getListadoParticipantes(capacitacion_id).ToList();
            return Json(data, JsonRequestBehavior.AllowGet);

So, the question is, what am I doing wrong? Because the data variable has values, and the capacitacion_id variable is passed correctly...  But does not populate de grid.

Thanks in advance.

IR Isuriya Rajan Syncfusion Team January 23, 2017 03:44 AM UTC

Hi Dayne, 
Query #1: But, by using this syntax Html.Syncfusion().Grid() to build the Grid, I don´t have the option to Filter like Excel  
We can enable the excel filter for Syncfusion grid.For this we have a method called  enableFiltering.By using this we can enable filtering. 
Please refer the below online documentation and sample link: 
Query #2: child data does not load properly 
Please refer the below code snippets for controller side. 
  public ActionResult ChildData(DataManager dm,int ? EmployeeID) 
            IEnumerable data = OrderRepository.GetAllRecords().ToList(); 
            DataResult result = new DataResult(); 
            DataOperations operation = new DataOperations(); 
            result.result = data; 
            result.result = operation.Execute(data, dm); 
            result.count = data.AsQueryable().Count(); 
            return Json(result, JsonRequestBehavior.AllowGet); 
Please refer the below sample for your reference: 

Isuriya R 

Live Chat Icon For mobile
Up arrow icon