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

Server-side grouping with dynamic grid : NotFetched exception

5 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Syleps
Top achievements
Rank 1
Veteran
Syleps asked on 06 Apr 2021, 10:39 AM

Hi

I'm trying to set up group management in a grid.
In my case, I'm  

  • in ASP.NET MVC
  • with dynamic grid (Html.Kendo().Grid<dynamic>)
  • full server side operations :

     grid.DataSource(dataSource => dataSource
            .Custom()
            .Type("aspnetmvc-ajax")
            .Transport(t => t.Read(read => read.Action("ReadData", "Grid").Type(HttpVerbs.Post)))
            .GroupPaging(true)
            .Batch(false)
            .AutoSync(true)
            .PageSize(10)
            .Schema(s => s.Data("Data").Total("Total").Model(model => ...))
    .ServerFiltering(true)
    .ServerGrouping(true)
    .ServerPaging(true)
    .ServerSorting(true)


    I read the following thread which looks a bit like my problem:
    https://www.telerik.com/forums/how-do-i-perform-server-side-grouping-and-aggregating

    and the answer :
    https://demos.telerik.com/aspnet-mvc/grid/customajaxbinding

    I was inspired by this to make a POC.
    In my grid/ReadData(request), I have something like that

    DataSourceResult result = <get data>;
    if (!request.Groups.Any()) return result; // No Group
    // One group
    return newDataSourceResult{
    Data=new List<AggregateFunctionsGroup>{
    new AggregateFunctionsGroup
    {
    Key = "Value", Member = request.Groups[0].Member, Items = result.Data
    }},
    Total=result.Total;
    }


    Of course, in my test, all rows have the value "Value" in the grouping column.

    At runtime, the first time, without group, everything is OK : I have my first 10 records from the table (which has several thousand records)
    I drag and drop the column in the grouping bar, and it's ok too : I have my accordion bar with the good column/value
    But, when I open the accordion, I have an issue :
    Uncaught TypeError: Cannot read property 'notFetched' of undefined
     kendo.all.js:8374  if (lastItem.notFetched) {

     
     I tried again by not returning the Items in AggregateFunctionsGroup
     On open, I receive a readata with a filter corresponding to my column / value and I return my data 
     (the same as during the first execution because all my rows have the same value in the grouping column)
     And I have the same issue.
     
    At start, I was with Kendo 2021 R2. But as I saw that there was a fix on this subject, I preferred to install the latest version (R3),
    but of course with the same result.

    Can you tell me if I am returning bad Data (or Total ?), or if the bug (of R1) is still there?
    Unless groups don't work with grid<dynamic>?

    Maybe it is necessary to return all the records in the "Item", and not just the first 10? (in my case, several thousand)

    Regards

    5 Answers, 1 is accepted

    Sort by
    0
    Anton Mironov
    Telerik team
    answered on 09 Apr 2021, 09:42 AM

    Hello Syleps,

    Thank you for the code snippets and details provided.

    I am trying to reproduce the pointed faulty behavior. No success for now. 

    The fastest route to getting you up and running is if you could provide a runnable, isolated, sample project. Examining this project will let us replicate the issue locally and further troubleshoot it.

    In order to help you create the reproducible, I have gone ahead and created a starter project for you. It already has all the dependencies and a view/controller with a Grid(dynamic MVC).

    Please take the following steps:

    1. Download, unblock and extract the attached solution
    2. Open it in  VS2019 and update the following files with your problematic code
    2.1 Controllers/GridController.cs
    2.2 Views/Home/Index.cshtml
    3. Run the project and confirm that it reproduces the problem at runtime
    4. Close VS2019, then open the project in File Explorer and delete the bin and obj folders
    5. Zip up the solution and attach it to your next reply.

    Looking forward to hearing back from you.

     

    Kind Regards,
    Anton Mironov
    Progress Telerik

    Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

    0
    Syleps
    Top achievements
    Rank 1
    Veteran
    answered on 14 Apr 2021, 07:00 AM

    Hi,

    Thanks a lot for the zip. With him I was able to find very quickly where the problem comes from.
    This is when we activate group paging (.GroupPaging (true))
    Attached is the modified index.cshtml (I cant return all zip : too big)
    Regards

    0
    Anton Mironov
    Telerik team
    answered on 16 Apr 2021, 02:30 PM

    Hello Syleps,

    I am glad to hear that the recommended approach achieves the desired behavior.

    If further assistance is needed, do not hesitate to contact me and the team.

     

    Greetings,
    Anton Mironov
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

    0
    Syleps
    Top achievements
    Rank 1
    Veteran
    answered on 19 Apr 2021, 07:49 AM

    Hi,

    I think we misunderstood each other. Using your example I was able to find the origin of the problem, but the bug is still there.
    If we set the group paging to true the grid doesn't return the values. Javascript error :

    Uncaught TypeError: Cannot read property 'notFetched' of undefined
     kendo.all.js:8374  if (lastItem.notFetched) {

    So my question is:

    - either it can't work, and I would like to know why
    - either the grid component has an issue,
    - either it's the return of the data from the server which is erroneous. In this case what should we return?

    Regards

    0
    Anton Mironov
    Telerik team
    answered on 22 Apr 2021, 07:43 AM

    Hello Syleps,

    I added the following row to the sample project and it is working as expected:

    .GroupPaging(true)
    Attached is the sample with the implementation above included.

    In this case, I would recommend double-checking for one of the following:

    • The group paging functionality is not supported for endless scrolling-enabled grids.
    • Group paging is not compatible with SignalR binding.

    Kind Regards,
    Anton Mironov
    Progress Telerik

    Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

    Tags
    Grid
    Asked by
    Syleps
    Top achievements
    Rank 1
    Veteran
    Answers by
    Anton Mironov
    Telerik team
    Syleps
    Top achievements
    Rank 1
    Veteran
    Share this question
    or