Hello,
I've read through countless forums related to this topic, and found the conclusions dubious if outright not applicable/working (different versions, requirements, etc).
I am currently using version [2012.3.1129.1050], possibly upgrading to another version soon.
Problem:
It's simple -- there is a RadGridView with grouping enabled, user may create multiple nested group layers.
AutoExpandGroups="False", so any rebind starts with all groups collapsed.
For particular rebinds, this is not desirable, as the user would like to retain their contextual display state (e.g. expand/collapse state of every group, scroll positions, etc -- for this thread, I'm only seeking feedback on the expand/collapse topic).
Goal:
Before rebind, capture the expand/collapse state of each group.
After rebind, reinstate each group's former state.
Approaches:
(tried several with limited success -- just looking for an official recommendation on approach)
Reinstating seems simple enough, the RadGridView provides convenient methods
But capturing has been an unexpected challenge, I'm looking for an efficient way to survey all groups to identify which are expanded.
In case this is helpful for anyone else, here's my painful progression of trials, so you could save yourself time:
1. Instead of rebind, implement a selective update of the bound source items, then notify.
Yes, this retains the grid's overall display state, however the updated item attribute(s) could affect whether the affected row(s) need to be moved to a different group, require refresh of aggregations, etc.
So a rebind would be much cleaner.
2. Loop through RadGridView.Items.Groups.
This involves recursively traversing all subgroup levels for nested situations (doable, but I'm hoping there is a simpler way to interrogate all groups easily). Also, the IsExpanded property is available on GridViewGroupRow, not IGroup itself.
For some reason, couldn't figure out (feel free to knock me) how to access the relevant GridViewGroupRow...
3. Loop through GridViewGroupRows.
Tried to access this via RadGridView.ChildrenOfType<GridViewGroupRow>(), however was empty. Other ideas also failed.
So I still couldn't figure out (feel free to knock me harder) how to access GridViewGroupRows on demand...
4. Leverage the GroupRowIsExpandedChanged event.
This at least provides a handle to the elusive GroupRow (when a group is clicked via UI). I can therefore check IsExpanded at runtime and maintain an internal record of IGroup states up until a rebind, then reinstate after rebind. There are various cycle nuances to this, but no major hurdles.
However, if you programatically expand/collapse (for example, invoke RadGridView.ExpandAllGroups), some unexpected and delightfully frustrating inaccuracies plague the internal record of states. Such as, only a fraction of the expanded groups get recorded. Also, adding/removing groupings lead to additional sync issues. Flaky.
Ideally, I don't want to depend on a realtime event like this, too unreliable. Would prefer the simple ability to just access all of the RadGridGroupRows on demand, and reliably interrogate which have IsExpanded = true.
Please point me toward enlightenment, have been wandering painfully through too many insufficient solutions...
Thanks!
I've read through countless forums related to this topic, and found the conclusions dubious if outright not applicable/working (different versions, requirements, etc).
I am currently using version [2012.3.1129.1050], possibly upgrading to another version soon.
Problem:
It's simple -- there is a RadGridView with grouping enabled, user may create multiple nested group layers.
AutoExpandGroups="False", so any rebind starts with all groups collapsed.
For particular rebinds, this is not desirable, as the user would like to retain their contextual display state (e.g. expand/collapse state of every group, scroll positions, etc -- for this thread, I'm only seeking feedback on the expand/collapse topic).
Goal:
Before rebind, capture the expand/collapse state of each group.
After rebind, reinstate each group's former state.
Approaches:
(tried several with limited success -- just looking for an official recommendation on approach)
Reinstating seems simple enough, the RadGridView provides convenient methods
- ExpandGroup(IGroup)
- CollapseGroup(IGroup)
But capturing has been an unexpected challenge, I'm looking for an efficient way to survey all groups to identify which are expanded.
In case this is helpful for anyone else, here's my painful progression of trials, so you could save yourself time:
1. Instead of rebind, implement a selective update of the bound source items, then notify.
Yes, this retains the grid's overall display state, however the updated item attribute(s) could affect whether the affected row(s) need to be moved to a different group, require refresh of aggregations, etc.
So a rebind would be much cleaner.
2. Loop through RadGridView.Items.Groups.
This involves recursively traversing all subgroup levels for nested situations (doable, but I'm hoping there is a simpler way to interrogate all groups easily). Also, the IsExpanded property is available on GridViewGroupRow, not IGroup itself.
For some reason, couldn't figure out (feel free to knock me) how to access the relevant GridViewGroupRow...
3. Loop through GridViewGroupRows.
Tried to access this via RadGridView.ChildrenOfType<GridViewGroupRow>(), however was empty. Other ideas also failed.
So I still couldn't figure out (feel free to knock me harder) how to access GridViewGroupRows on demand...
4. Leverage the GroupRowIsExpandedChanged event.
This at least provides a handle to the elusive GroupRow (when a group is clicked via UI). I can therefore check IsExpanded at runtime and maintain an internal record of IGroup states up until a rebind, then reinstate after rebind. There are various cycle nuances to this, but no major hurdles.
However, if you programatically expand/collapse (for example, invoke RadGridView.ExpandAllGroups), some unexpected and delightfully frustrating inaccuracies plague the internal record of states. Such as, only a fraction of the expanded groups get recorded. Also, adding/removing groupings lead to additional sync issues. Flaky.
Ideally, I don't want to depend on a realtime event like this, too unreliable. Would prefer the simple ability to just access all of the RadGridGroupRows on demand, and reliably interrogate which have IsExpanded = true.
Please point me toward enlightenment, have been wandering painfully through too many insufficient solutions...
Thanks!