I have a requirement for a project that I'm having some difficulty getting to work. I've looked at the following post, http://www.telerik.com/community/forums/aspnet-ajax/grid/client-side-expand-collapse-of-group.aspx, but it only takes me so far. For my page, I have a grid that is configured for client-side grouping. I have a requirement that the expanded groups are persisted on grid rebind. There is a control on the page that allows the user to select from a list of items that translate to the groups in the grid. So, the user selects 3 items in the list and there are 3 groups of those selected items in the grid, the user selects 5 items from the list and there are 5 groups in the grid, etc. In other words the number of groups is variable based on user selection.
I've set up a web service to handle the persisting of the group information via ajax callback from the page, and that all works fine. The problem I'm having is that there isn't any way to get the selected group information in the OnGroupExpanded or OnGroupCollapsed events. It appears that the sender is the grid itself and the event args are empty? I currently have the following code, based on the link above:
<
telerik:RadGrid
...>
<
ClientSettings
EnableRowHoverStyle
=
"false"
>
<
ClientEvents
OnGroupExpanded
=
"groupExpanded"
/>
</
ClientSettings
>
...
</
telerik:RadGrid
>
function
groupExpanded(sender, e) {
var
grid = $find(sender.get_id());
var
expandedGroupItems = grid._expandedGroupItems;
var
lastItemId = expandedGroupItems[expandedGroupItems.length - 1];
alert(
"Owner TableView: "
+ lastItemId.split(
'!'
)[0]);
alert(
"Table Row Index : "
+ lastItemId.split(
'!'
)[1]);
}
In the example, it shows getting the row index by parsing the item ID and then this ID can be used server-side to set the row expansion. However with variable groups, that ID is also variable (I've tested as such, the IDs change as groups are added or removed). Is there really no way to get at the group item that was expanded or collapsed directly? What I'd like, is to use our own internal unique id for the group, but it doesn't look like any group information is exposed at all in these events.
Also, I'd like to say that the documentation for OnGroupsExpanded and OnGroupsCollapsed is incorrect. It states that the sender is a GridDataItem, when in fact it is the grid itself. It is a bit confusing.
Any and all help would be greatly appreciated.
Thanks,
-Matt.