Sunday, February 19, 2012

Hiding a table row depending on page number?

Hi, Everyone.
i am wondering if there is some way to hide a table row depending on the page number.
I have tried to find a way to access the global page number to use it in an expression for the visibility property on the table row, but i havent found anything useful.

Hi Palmie,

Unfortunatelly, global variables can be used only in the page header and footer. Maybe, if you know the number of columns in a page, then you can operate with the RowNumber variable (just an idea Wink ).

Regards,

Janos

|||Do you mean something like this ? :
IIF(RowNumber(Nothing) > [a number], True, False)

When i use that expression it hides the row on every page.
|||

Are you trying to show something only on page 1, or what exactly?

>L<

|||Yes, sorry if i wasnt being clear about that, i have a Table header row that i only want to show on the first page of the report.
|||

OK then let's try the obvious things first:

If it is a group header, try hiding duplicates for a full dataset scope. If it is really a table header, make sure that "repeat on new page" is turned off.

You may have to turn "Can Shrink" on for all such items to get the effect you are after...

If none of these ideas work for you, tell me more about this table header and how it is placed, and I'll give it a shot...

For example maybe one of the following holds true:

it is a group header, and you want multiple repetitions, just not on any pages but #1 it is a table header and the table is contained in another control, so the table repeats multiple times in the report|||Hey again and sorry for the late reply.

The table with the header row that i want to hide looks like this:
The table is not inside another control.
It is not a group header, just a table header.

The table has 3 header rows
Row 1 contains a subreport with a few textboxes and an image. This should be visible on all the pages. Row 2 contains a rectangle with some textboxes, This is the row i only want to show at the first page. Row 3 is the actual header for the detail rows and should be repeated on every page.|||

OK, gotcha. Assuming I have repro'd your situation correctly, this should work:

1. Add the following to your Report code:

Code Snippet

Public hideRow As Boolean = False


Function hideSpecialRow() As String
hideRow = True
Return ""
End Function

2. Add an expression to some textbox in header row #3 ( the one with the "actual header for the detail rows) or anyplace after row #2 I think would work. If it is an empty textbox, just make the expression

=Code.hideSpecialRow()

... but if you do not have an empty textbox, use this (make sure that you use & and not + in case, as in my example, the other value is not a string):

Code Snippet

=Max(Fields!Locale.Value) & Code.hideSpecialRow()

3. Select the row (not the textboxes) in row # 2. Set its Visibility property to:

Code Snippet

=Code.hideRow

Whaddya think?

>L<

|||This looked like it could solve the problem, but I cant get it to work.

I put the call for the function below the header row that i want
to hide, and I set the visibility property to the bool hideRow and it
is still repeating itself.

I checked the value of the bool before and after the call and it changes value
from False to True.

When i put a textbox with "=Code.hideRow.ToString" in the rows i get that
it is false in the row that is supposed to be hidden and true in the rows below that, and the header rows looks the same on every page.|||

>>When i put a textbox with "=Code.hideRow.ToString" in the rows i get that
it is false in the row that is supposed to be hidden and true in the rows below that, and the header rows looks the same on every page.

<<

It should be false in the row that is supposed to be hidden on page 1, and true *always* after that. For example it should be true in the first header row on page 2, as well as all subsequent rows. Can you verify that it is?

Assuming that it is, then there might be something else stopping the Visibility thing from working properly for you.

>>and I set the visibility property to the bool hideRow

What happens if you just edit the visibility property you have set here to =False? You should not see that row at all, even on page 1. Does this work as expected for you? (I just want to verify that it's being set in the right place and that nothing else is involved. -- I did test what I wrote and it did work <s>.)

>L<

|||

Lisa Nicholls wrote:

>>It should be false in the row that is supposed to be hidden on page 1, and true *always* after that. For example it should be true in the first header row on page 2, as well as all subsequent rows. Can you verify that it is?<<


It is false on the first page and its the same on the other pages.
It looks like RS copies the table header from the first page to the others.

Lisa Nicholls wrote:

What happens if you just edit the visibility property you have set here to =False? You should not see that row at all, even on page 1. Does this work as expected for you? (I just want to verify that it's being set in the right place and that nothing else is involved. -- I did test what I wrote and it did work.


If i set the "Hidden" property to =True (if you meant True instead of False), The row is hidden on all the pages.
|||

Yes, I did mean =True <s> Sorry.

>>

It is false on the first page and its the same on the other pages.
It looks like RS copies the table header from the first page to the others.

<<

Then something is wrong. If I put =Code.hideRow in the first header row, it is False on page 1, False on page 2, and then True on all other pages. This is because I set it in the third header row on page 2, so it is not True until *after* header row 1 on page 2.

OK, I see something else is involved here. The report I happened to pick to try this has the table inside a list element. I am not sure why that makes a difference but when I remove the list element I see what you describe. I'm sorry about this. I will try to figure out why it doesn't behave the same way and write back.

>L<

|||

OK -- I have pretty much confirmed that this works *IF* the table is in a list. This requires the list to have a group expression.

What happens is that the table's header row is suppressed for all the instances of the table inside that list. You might have multiple instances of the table on one page or, if you say "page break after" on the table, you would only see the header row in question on page 1. Which works exactly the way you want.

This is the bummer part -- it doesn't seem to work if you use a constant for the list's group expression, or anything that evaluates to a constant value, so if you don't actually need a group at all it won't work.

My original example happened to have a group, and I didn't notice that it had the table inside a list... because I generated the example using the report wizard <sigh>.

I don't know if the behavior (the table header seeming to be copied from the first page, without re-evaluation, if there is no group or list) is a bug or an optimization.

I don't suppose your table *has* a group and putting it inside a list is a viable possibility?

>L<

|||Nope, the table doesnt have a group. I tried putting the table in a list and just set an Id value for the report as group expression in the List but i still got that same problem where the report seems to copy the first page.
|||

Well, like I said, this only is workable when the table *does* have a group and it can't be a group that doesn't change (I did try that <sigh>...) I'm not sure why this is because I am definitely using table header, not group header, but it made all the difference.

If I can think of a different approach I will post back here.

>L<

No comments:

Post a Comment