Collapsed by default rows in Grid

1 Answer 35 Views
Grid
Stanil
Top achievements
Rank 1
Stanil asked on 29 May 2024, 12:55 PM
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

Sort by
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:

If you have something different in mind, please share a stackblitz example with your scenario.

 

Best Regards,
Konstantin Dikov
Progress Telerik

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

Stanil
Top achievements
Rank 1
commented on 24 Sep 2024, 07:59 AM

Hello Konstantin,

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.

 

Stanil
Top achievements
Rank 1
commented on 25 Sep 2024, 12:45 PM | edited

Hello Yanko and thank you for you reply,

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: 

const initialDataState: State = {
    sort: [{ field: "name", dir: "asc" }],
    take: 100,
    skip: 0,
    group: [
        { field: "VisualTypeName", },
    ],
};

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?

Stanil
Top achievements
Rank 1
commented on 26 Sep 2024, 08:26 AM

Ticket has been raised using the support center.
Yanko
Telerik team
commented on 26 Sep 2024, 12:37 PM

Hi, Stanil,

Thank you for this. We will continue the discussion of the matter there.

Tags
Grid
Asked by
Stanil
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or