R – MS Reportviewer – Save Expanded/Collapsed Nodes in ViewState

asp.netreportviewerviewstate

I have a report that's being populated from an ObjectDataSource. The report includes expandable/collapsible nodes per user.

I'm allowing the viewer to filter the report by setting the FilterExpression on the datasource, then calling ReportViewer1.LocalReport.Refresh(). This is done during PostBack.

This filters the results, but the state of the expanded/collapsed nodes is lost. Is there some way to store the expanded/collapsed nodes in the ViewState? Or is there a better way to accomplish this altogether?

Best Answer

I know its been a while since this question was asked, but since i had to go through this recently i want to share my experience with somebody who might be dealing with this.

It's tricky but if you add a multivalued parameter to your report and the values match the values in the toggable fields, then you can write a group expression in the grid (And in the labels so those go away too). Once that is done, you just have to keep track of what is toggled (this is hard, but is possible with javascript).

Basically, there are two of the hidden child controls in the reportviewer control (indexes 4 & 5 in vs2008) that have the name of the event and the id of the table cell clicked, with this you cand build an array in javascript and keep track of the status of all toggable fields.

Related Topic