Lets say that I have 10 columns to view report and I want to hide 3 of these columns at runtime based on the value of parameter which the user would select. This can be easily done by setting the column visibility of each of these 3 columns based on the value of the aforesaid parameter. It's perfectly fine up till here.
The problem is when the report shows up (with 3 columns hidden) the remaining 7 columns take up the place of the hidden columns and as a result the overall width of the table reduces accordingly. I do not want this to happen. i.e. I want the table width to remain constant.
That is to say the remaining columns width should somehow be able to expand so that the original overall width of the table remains same.
Is this possible to achieve?
Column width is not natively expression based, but you can achieve something like this. Whether it works for you I think will depend on your specific report layout and how the workaround affects any other elements.
Anyway, a simple example. I've created a report against a DataSet with three fields:
I've set val2
to have its visibility controlled by a boolean parameter, HideColumn
. This works fine.
Note that there are actually five columns in the table. For val1
and val3
there are actually two columns, and I have merged the fields in the columns together.
The key here is that when HideColumn
is set to true, we show the extra columns for val1
and val3
, and when it's false we hide the columns - basically the opposite of the visibility for val2
.
SSRS will adjust the width of the merged fields accordingly based on which columns are visible:
So in this case it's working as required. For your example you'll need to think about sizing and the required width of these extra columns, but the principle is the same.
This will only work for set columns, i.e. not a matrix, but hopefully will be sufficient for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With