Hello, could you please help me find a way to keep the grid rows collapsed by default when a page loads ? I have been trying for 2 days to find a way a to do it and I still cannot.
1 Answer, 1 is accepted
1
Konstantin Dikov
Telerik team
answered on 29 May 2024, 07:12 PM
Hi Stanil,
The expanded state of the detail rows is determined by the expanded field in the data items. You can check the following example where all detail rows are collapsed initially:
Thank you for your reply. I have seen this example and I am applying the same approach, but it does not work. I have also tried to change the "expanded" property to "false" on few places in the code, which also did not work. Do you know what could be the reason making the grid expand by default ? I have tried so many different ways to enforce it to be collapsed by default, but it simply does not work.
Yanko
Telerik team
commented on 24 Sep 2024, 01:04 PM
Hello, Stanil,
The `expanded` state of each dataItem is kept in the app state and is updated in the onExpandChange event. The `expanded` state needs to be added to the data and is handled by the onExpandChange you can check onExpandChange event and its value.
I can help you with a solution if you can provide me with a runnable example or more details on the use case of the described functionality.
I look forward to resolving the matter and await your response.
I am working on a application that uses the PowerBI Client library, and when loading the grid the dataState is passed to the grid, and this is the initial state:
Could it be the reason for the grid being expanded ?
Yanko
Telerik team
commented on 25 Sep 2024, 02:46 PM
Hi, Stanil,
Thank you for the provided code.
The reason behind this behaviour may come from the use of both detail rows and grouping in the same Grid. Since the Grid will fire `onExpandChange` event for both expanding/collapsing the groups and the detail rows, additional logic must be added to it.
To determine if a group item is firing the `onExpandChange` event or a dataItem we need to check if an "aggregates" object exists in the item (which is available for groups only). Please check this example that has both functionalities enabled:
The reason for the grid being expanded can be related to the `expanded` property and the `onExpandChange` event, can you please provide more details about their implementation or provide a runnable example that replicates the faced scenario?