Showing posts with label report. Show all posts
Showing posts with label report. Show all posts

Friday, 19 September 2014

Highlight selected row on report in SQL Server Reporting Services

I have made hundreds of reports using PowerBuilder datawindows. It is a great environment for designing complex reports with lots of controls and events. Nowadays I use SQL Server Reporting Services and I am disappointed how complex it is. Despite lots of properties it is missing some basic features like: expression validating in editor, data preview in design view, scrollbars, etc.
One of missing features is highlighting selected row. Highlighting selected row is very useful in master-detail reports. By clicking on a master row the detail report is being refreshed. User want to see which master row is currently selected. In this post I show how to highlight selected row on report in SSRS.

The final effect will look like on this screen-shot.
 You might also watch a video how it works:


 

Highlighting selected row in Reporting Services report

 I use Report Builder 3.0 for this tutorial. I assume that you have already created a master-detail report and you only need to add highlighting. If you don't have the master-detail report you can follow this tutorial: http://www.codeproject.com/Articles/270924/Master-Details-Report-in-SSRS Lets say you have a master report with dsMaster data set and a detail report with dsDetail data set. Also you have a parameter, lets say @masterRowId. This parameter is used to pass a value from the master report to a child report, so the child knows which records to display.
Now it is time to add highlighting selected row to the master report:
  1. Right click on dsMaster data set and choose Dataset Properties
  2. Click on Parameters tab
  3. Add parameter - @masterRowId and assign it value of -1 (or any dumb value which is not present in your master table)

  4. Click Ok to close the Properties
  5. Select data row in the master report by right clicking on the row indicator
  6. In Properties window locate BackgroundColor setting
  7. Expand the list of possible values for the BackgroundColor setting and choose the last - Expression
  8. Enter following formula:

  9. Click Ok, save reports.
That is all. You have just added highlighting selected row feature to your SSRS report.