Tuesday, February 14, 2012

Customizing report columns count at runtime

Hello all. In my application I have some rdl file that determines
general look of my report. Also I have a table that has 20 columns I
have stored proc that returns dataset that also has 20 columns but may
have filled less than 20 columns (5 for example). The problem is how
to hide another (20-n) columns.
Now I simply pass params to report and hide columns according to these
params.In this case I have normally rendered report on screen and I'm
experiencing problems with printing: I have my "n" columns printed
normally then long space and table end line ( in another printed
page ) what looks ugly.
So my question is: can I dynamically manage columns count ( without
having to generate rdl programatically :) ), for example pass report
param "ColumnsCount" and then have so much columns as I want (also
apply binding values for these columns)
or
is there a method how to hide my (20-n) columns and minimize table so
I do not have that big white space and ugly line after it.
Any ideas?
Thanks in advanceOn Apr 30, 4:15 am, mblishch <mykhaylo.blis...@.gmail.com> wrote:
> Hello all. In my application I have some rdl file that determines
> general look of my report. Also I have a table that has 20 columns I
> have stored proc that returns dataset that also has 20 columns but may
> have filled less than 20 columns (5 for example). The problem is how
> to hide another (20-n) columns.
> Now I simply pass params to report and hide columns according to these
> params.In this case I have normally rendered report on screen and I'm
> experiencing problems with printing: I have my "n" columns printed
> normally then long space and table end line ( in another printed
> page ) what looks ugly.
> So my question is: can I dynamically manage columns count ( without
> having to generate rdl programatically :) ), for example pass report
> param "ColumnsCount" and then have so much columns as I want (also
> apply binding values for these columns)
> or
> is there a method how to hide my (20-n) columns and minimize table so
> I do not have that big white space and ugly line after it.
> Any ideas?
> Thanks in advance
You should be able to toggle visibility of the columns in the report
via an expression. Right-clicking the column in the table control and
selecting properties and select the tab for visibility and then enter
an expression that checks for the sum of the column's value. Something
like this should work:
=iif(Sum(Fields!ColumnItemX.Value) > 0, "true", "false")
Also, you might want to make sure that for individual cells, the
shrink to fit (or similar wording) is selected and that you
conditionally set border styles based on if the column is visible
(via, Properties -> Border Style: =iif(Sum(Fields!ColumnItemX.Value) >
0, "Solid", "None"))
Hope this helps.
Regards,
Enrique Martinez
Sr. Software Consultant

No comments:

Post a Comment