What is the easiest way to check on the client side if RadGrid is in grouped state or ungrouped?

0 Answers 98 Views
Grid
Olga
Top achievements
Rank 1
Iron
Olga asked on 05 Dec 2023, 06:44 PM

Hello,

I have a grid that could be grouped by one of the columns or ungrouped. GroupLoadMode = "Client".

What is the easiest way to get the grouping state (grouped or ungrouped) of the grid on the client side.

Thanks,

Olga

Rumen
Telerik team
commented on 07 Dec 2023, 09:05 AM

Hi Olga,

You can check whether the grid is grouped or ungrouped on the client-side using one of the following approaches:

 

var gridElement = $find("<%=RadGrid1.ClientID%>").get_element();
var groupHeaders = gridElement.querySelectorAll(".rgGroupHeader"); 
var isGrouped = groupHeaders.length;
if (isGrouped >0) {
    console.log("The grid is grouped.");
} else {
    console.log("The grid is not grouped.");
}

or through the 

$find("<%=RadGrid1.ClientID%>")._groupPanel._items.length setting. If it is 0 then the grid is ungrouped, if it is 1 or more it is grouped.


Olga
Top achievements
Rank 1
Iron
commented on 12 Dec 2023, 06:47 PM

thanks a lot!

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Olga
Top achievements
Rank 1
Iron
Share this question
or