Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1290
Sorting Grouped grid collapses child bands
posted

Hi, I have a grid in Outlook Group By mode. When I expand a group or several groups, then click a column in a group to sort it by that column all the expanded groups are collapsed after postback. Is there any way to keep them expanded?

Thanks.

  • 45049
    posted

    Not through any functionality built-in to WebGrid, no.  Adding or removing a level of grouping to WebGrid, or sorting the grid on the server (including via AJAX), requires it to databind itself again.  This means that all the rows that were previously in the grid are discarded, and new rows are created.  Since the old rows aren't saved, their expanded states also aren't saved.

    You would need to keep track of some information about what rows are expanded before the group or sort takes place, see if corresponding rows exist on your page after the group or sort, and expand any rows that match what was previously expanded.