Bernard Polman
Bernard Polman

Reputation: 855

SSRS - hide a column and change width of other column

I'm creating a report that has 5 columns. However, one column can have no data and in that case I need to hide it. This works using the 'Hidden' property of column but when the column is hidden, I want to make the first column wider. Is there any way to do this in expression?

The only solution I found is to have multiple same tablixes with different column count and then show or hide each tablix appropriately if the specific column has no data. (by checking 'Max' value in column).

Upvotes: 0

Views: 1128

Answers (2)

Daniel Ramirez
Daniel Ramirez

Reputation: 1

Create a new column with the same data in it as the one whose width you want to widen. Set the width of the new coto the width it should be with the empty column hidden (the sum of the width of the original narrower data column plus the width of the empty column). Then you would toggle the visibility of the two identical columns to be opposite one another so that the wider one is visible when the empty column is hidden and so the narrower one is visible with the empty column is visible. Limitations: would be a pain if it was more than one column.

Upvotes: 0

Steve-o169
Steve-o169

Reputation: 2146

Unfortunately, it's not possible to enter an expression to the column width property but if you simply need to change the width of one other column when the first is hidden, I've come up with a workaround that works fairly well.

The idea is a little easier and requires less data to load than your current solution. Basically, you'll create an identical width column that is simply empty -- but set the borders to appear as if it is simply part of another column. So you'll simple reverse the expression used to hide the column with no data in the hidden property. To achieve this, depending on where you choose to add the extra space column, you'll have to adjust the borders of the adjoining cells where there is no right border on the cell to the left and a left border on the cell to the right. Depending on your layout, you would only need a top and bottom border on the extra space column cells.

I did something similar with a report that has 3 pages and 11 columns -- but 8 of the columns changed from page to page. I had to hide one column, show another, and used expressions in column headers and detail rows to simply change the data in each column based on a field that returns the type of the data.

Upvotes: 1

Related Questions