This is a migrated thread and some comments may be shown as answers.

Server Grouping with virtualisation

5 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Geetha
Top achievements
Rank 1
Veteran
Geetha asked on 01 Jul 2020, 09:07 AM

Hello All, I followed this example https://demos.telerik.com/aspnet-mvc/grid/server-grouppaging-virtualization to implement in my project, however i am getting error while doing grouping with mutiple columns, i tried searching in the forms for a solution but no luck. 

This is my Code below

Html.Kendo().Grid<Project.ViewModels.ListViewModel>()
    .Name("GridName")
    .Columns(columns =>
    {
        columns.Select().Width(50).HtmlAttributes(new { @class = "checkbox-align" }).HeaderHtmlAttributes(new { @class = "checkbox-align" });
        columns.Bound(p => p.Company);
        columns.Bound(p => p.Country);
        columns.Bound(p => p.City);
        columns.Bound(p => p.CodeSociete);
    })
    .ToolBar(toolbar =>
    {
        toolbar.Create();
 
    })
    .ColumnMenu(col => col.Filterable(true))
    .Height(550)
    .Sortable(sortable=>sortable.Enabled(true))
    .Navigatable()
    .Resizable(r => r.Columns(true))
    .Groupable()
    .Filterable(filterable => filterable
        .Enabled(true)
        .Extra(true)
        .Operators(operators => operators
            .ForString(str => str.Clear()
                .StartsWith("Starts with")
                .IsEqualTo("Is equal to")
                .IsNotEqualTo("Is not equal to")
            ))
        )
    .Scrollable(scrollable => scrollable.Virtual(true))
    .Events(events => events.DataBound("onDataBound"))
    .DataSource(dataSource => dataSource
    .Ajax()
    .Events(events =>
        events.Error("error_handler")
    )
    .Model(model =>
    {
        model.Id(p => p.ID);
    })
    .GroupPaging(true)
    .PageSize(50)
    .Read("DetailProducts_Read", "List")
    )
)

 

My Controller class ListController.cs

[HttpPost]
        public ActionResult DetailProducts_Read([DataSourceRequest]DataSourceRequest request)
        {
 
                IEnumerable<List_Entity> list = myService.getAll(out totalRecords, this.UserId.ToString());
                listDB = list
                    .Select(f => new ListViewModel()
                    {
                        ID = f.ID,
                        Company= f.Company,
                        Country= f.Country,
                        City= f.City,
                        CodeSociete= f.CodeSociete

,
                    }).ToList();
 
        DataSourceResult result = listDB.ToDataSourceResult(request);
               
                result.Total = (int)totalRecords;
                return new JsonResult() { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = Int32.MaxValue };
    }

 

When i run the application virtualisation,sorting,filtering,paging works perfectly without grouping, when i try to group with first colum drag and drop all the events work perfectly, but when i try to drag second column to grouping i get the following error (errorDebug.png) and in the browser console window i have this error

Uncaught TypeError: Cannot read property 'length' of undefined
    at Function.map (jquery-1.10.2.js:789)
    at init.groups (kendo.aspnetmvc.js:212)
    at proxy (jquery-1.10.2.js:841)
    at init.groups (kendo.all.js:6508)
    at init._readData (kendo.all.js:7371)
    at init.success (kendo.all.js:7575)
    at success (kendo.all.js:7527)
    at Object.n.success (kendo.all.js:6404)
    at fire (jquery-1.10.2.js:3062)
    at Object.fireWith [as resolveWith] (jquery-1.10.2.js:3174)

 

Could you please help me to resolve this issue?

 

 

 

5 Answers, 1 is accepted

Sort by
0
Geetha
Top achievements
Rank 1
Veteran
answered on 03 Jul 2020, 07:56 AM
Any help please?
0
Tsvetomir
Telerik team
answered on 03 Jul 2020, 08:09 AM

Hi Geetha,

I have investigated the provided code snippets and it appears that they are set up correctly except for the ActionMethod. I suppose that the JsonResult is formatting the response in a way that the grid cannot parse correctly. 

Is it possible for you to alternate it as shown here:

var jsonResult = Json(result, JsonRequestBehavior.AllowGet);
  jsonResult.MaxJsonLength = int.MaxValue;
  return jsonResult;

Also, the multi-level grouping is supposed to be working correctly as our demo utilizes 2 groups by design:

https://demos.telerik.com/aspnet-mvc/grid/server-grouppaging-virtualization

In case the issue persists, let me know.

 

Kind regards,
Tsvetomir
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Geetha
Top achievements
Rank 1
Veteran
answered on 06 Jul 2020, 07:56 AM

Hello Tsvetomir, Thank you for your reply, actually i tried with this and i am still getting the same error while grouping  with multiple fields. 

In the example above provided, the datasaource is using custom binding and i am using Ajax. how is it different? can this be a problem for grouping?

0
Geetha
Top achievements
Rank 1
Veteran
answered on 06 Jul 2020, 08:33 AM
Hello, by the way the myService.getAll method gets the data from SQL server through Dapper interface, we are not using the EntityFramework, is there any problem in conversion to ViewModel?
0
Geetha
Top achievements
Rank 1
Veteran
answered on 06 Jul 2020, 08:39 AM

Hello i resolved the problem, set ServerOperation(false), i refered this article 

https://www.telerik.com/forums/mvc-grid-bound-to-dynamic-data-only-sends-empty-object-to-controller

 

Tags
Grid
Asked by
Geetha
Top achievements
Rank 1
Veteran
Answers by
Geetha
Top achievements
Rank 1
Veteran
Tsvetomir
Telerik team
Share this question
or