Unplanned
Last Updated: 26 Sep 2024 13:12 by ADMIN
Ron
Created on: 25 Sep 2024 10:35
Category: Grid
Type: Bug Report
1
Calling SetStateAsync on a grouped Grid increases the AggregateFunctions count of the GroupDescriptor

My scenario is a lot similar to this one and I call SetStateAsync to exit the edit mode. In addition, my Grid is grouped on initialization. I noticed that each time I call SetStateAsync, the AggregateFunctions count of the GroupDescriptor increases and one more identical AggregateFunction is added to the same GroupDescriptor. This results in slowing the editing process.

Here is a simpler reproduction: https://blazorrepl.telerik.com/wekZmTPE35YpD8f504.

3 comments
ADMIN
Hristian Stefanov
Posted on: 26 Sep 2024 13:12

Hi Ron,

Thank you for sharing your temporary fix here, publicly. It is highly appreciated that you are allowing other developers facing the scenario to benefit from it.

Regards,
Hristian Stefanov
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.

Ron
Posted on: 25 Sep 2024 19:51

A better version

    private async Task ExitEditAsync()
    {
        var state = GridRef?.GetState();
        state.OriginalEditItem = null;
        state.EditItem = null;
        state.InsertedItem = null;

        // This will fix the progressive slowness ---------------------------------------
        foreach (var item in state.GroupDescriptors)
        {
            // Remove the AggregateFunctions since SetStateAsync doubles them
            item.AggregateFunctions.Clear();
        }
        // This will fix the progressive slowness ----------------------------------------

        await GridRef?.SetStateAsync(state);
    }

Ron
Posted on: 25 Sep 2024 19:00
I used the following code as a temporary fix in our project. The code sets the aggregate function count to 0 prior to SetStateAsync.



    private async Task ExitEditAsync()
    {
        var state = GridRef?.GetState();
        state.OriginalEditItem = null;
        state.EditItem = null;
        state.InsertedItem = null;


        // This will fix the progressive slowness ----------------------------------------
        // List to store GroupDescriptors
        List<GroupDescriptor> grpList = new();
        // Loop through the GroupDescriptors to store them
        foreach (var item in state.GroupDescriptors)
        {
            grpList.Add(item);
        }
        // Clear the GroupDescriptors
        state.GroupDescriptors.Clear();
        // Add the GroupDescriptors back to "state" var
        foreach (var item in grpList)
        {
            // Remove the AggregateFunctions since SetStateAsync increases them
            item.AggregateFunctions.Clear();
            // Add them back without AggregateFunctions
            state.GroupDescriptors.Add(item);
        }
        // This will fix the progressive slowness ----------------------------------------


        await GridRef?.SetStateAsync(state);
    }