Thursday, February 11, 2016

Programmatically Group/Ungroup Row in ReportViewer

Step by step tutorial of grouping or ungrouping report viewer in runtime.
When you export reportViewer to Excel format, it is very hard to manage/calculate the grouped row in excel especially when you want to add filter to each column. So, it would be better if you give your user a option to group/ungroup row.

This tutorial will provide you on how to programmatically group/ungroup row using ReportViewer parameter.

Note: This tutorial assume that you have done group row already.

1In the "Row Groups" Click the arrow icon of the topmost row, and click "Group Properties".

2In Group Properties window, select "General" tap, and then click "Add" button to add the group condition, click the expression icon

3Paste the code
=RowNumber(Nothing)
and click OK

4Run your application, you will see that the row is ungroup now

5In order to programmatically group/ungroup row, you can set the expression in step 3 to depend on ReportViewer parameter like this
=iif(Parameters!groupColumn.Value = "true", 1, RowNumber(Nothing))


Happy Coding!

No comments:

Post a Comment