Unplanned
Last Updated: 10 Jul 2024 14:22 by ADMIN
César
Created on: 09 Jul 2024 15:19
Category: Grid
Type: Bug Report
1
Unable to unselect all Grid items with header checkbox when Grid is inside ChildContent

We have a grid with a GridCheckboxColumn that we have configured through a '.unselectable-row' style so that certain elements cannot be selected (those elements with a padlock in the second column cannot be selected).

The grid works correctly in isolation, but when we add a TelerikLoaderContainer that is displayed during data loading process, the grid doesn't working properly: it is possible to select all the enabled elements of the grid using the button in the header of the checkbox column. However it is not possible to deselect them from the button in the header of the checkbox column when there is any unselectable element.

Here it is a link to REPL with a reproducible example: https://blazorrepl.telerik.com/GyYhYXPI24gIYgIJ03

To reproduce the problem, you sholud select all grid elements from the checkbox column header button and try to deselect them. You will not be able to deselect all the elements. 
Now comment the LoaderContainer component and repeat the test. You will see that now it is possible to deselect correctly all the elements.

How can we deselect all the elements from the header while keeping the loadercontainer?

1 comment
ADMIN
Dimo
Posted on: 10 Jul 2024 14:22

Hi César,

Thank you for the runnable REPL test page.

That's a very peculiar problem indeed. It seems to be related to the combination of two things:

  • The Grid is inside the ChildContent parameter of a component.
  • The selected items are overridden on the fly.

It's not clear what exactly is causing the difference in behavior, so we will have to invest more time for research when we get to this.

In the meantime:

You may need to adjust the logic to match better your scenario. The idea is to detect when the "changed" selected items actually match the current ones.

    private void OnSelect(IEnumerable<Product> selectedProducts)
    {
        int newSelectedItemsCount = selectedProducts.Count();
        int allItemsCount = Math.Min(GridPageSize, GridData.Count());
        int discontinuedCount = GridData.Where(x => x.Discontinued).Count();

if (newSelectedItemsCount == allItemsCount && discontinuedCount > 0 && SelectedReasons.Count() == allItemsCount - discontinuedCount) { SelectedItems = new List<Product>(); SelectedReasons = new List<Product>(); } else { SelectedItems = selectedProducts.Where(x => !x.Discontinued).ToList(); SelectedReasons = selectedProducts.Where(x => !x.Discontinued); } }

 

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!