Sunday, May 4, 2014

Fun with SSRS Rectangle objects.


One of the most misunderstood features of SSRS is the use of the Rectangles. At first glance, it may appear that rectangles are simply shapes you can add to your reports in the same way you would add circles, lines, and other shapes. That can’t be further from the truth. In fact, rectangles are one of the more powerful objects in SSRS. The main purpose of rectangles is not only to display a box, but instead group all other SSRS objects (tablix, matrix, graphs, text box, etc.) in to a defined area on the report body to allow for “grouped” configurations. Here is an example of a use a rectangles. Let’s say we have three SSRS objects - a chart, a tablix, and a text box.
When we run the report, the spacing changes so that the first tablix is displayed and unused space is added unnecessarily. Without using rectangles as containers, we are at the mercy of where the report rendering process displays the object.
 

 If I added the chart and the second tablix in the rectangle (i.e. green box) in the design mode I force the SSRS to display the tablix at a certain location.


When we run it the second time, the two sections are not generating the excessive space between to two charts but instead keeping the two objects within the rectangle.



As we see in these examples, If we place these on the report body, and display the reports, SSRS will display the objects right to left in processing the display, and once that item is complete, it will show the next object. This can produce unexpected object locations.  Again, to force SSRS to display report objects together, we include the report objects inside the rectangle. This keeps all these items grouped together.
 
Another example of rectangle object usefulness is to allow you to move around sections of report objects when editing. This can be really a time saver when you have spent a lot of time lining up report objects in different sections through spacing and you need to move that entire grouping of report objects without have to drag individual sections and repositioning the reports. If you always start with grouping you report layout inside rectangles, you an easily move these reports object simply by moving the rectangles. That approach saves me hours across report projects.
I always felt if Microsoft would have named the rectangle object the “Item Grouping” object that would make it clear to the report author that this object is not simply to draw a rectangle, but as a container grouping feature to define how objects are displayed on the report.

No comments: