Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Changing row formatting depending on the row number...
Changing row formatting depending on the row number... [message #69616] Thu, 25 August 2005 13:49 Go to next message
Frédéric Ferrant is currently offline Frédéric FerrantFriend
Messages: 75
Registered: July 2009
Member
Hello.

I understand the 'conditionnal formatting' stuff, but I'm trying to
format rows in a table depending on their number instead of a value
(even rows should be gry and odd rows white, for example).

Does anyone know if there exists a birt scripting variable indicating
the row number (I was thnking of something like 'number % 2 Equal 0',
but Ican't get the row number).

I tried a condition on a boolean on the row itself, (grey = !grey
Equal True), but it seems like the condition is checked for every cell
of the row, not row per row...).


Any idea?
Re: Changing row formatting depending on the row number... [message #69656 is a reply to message #69616] Thu, 25 August 2005 16:54 Go to previous messageGo to next message
David Trainor is currently offline David TrainorFriend
Messages: 23
Registered: July 2009
Junior Member
you should be able to set a global variable then access that variable in
the expression on the conditional highlighting using the mod code you
provided
Re: Changing row formatting depending on the row number... [message #69758 is a reply to message #69656] Fri, 26 August 2005 08:06 Go to previous messageGo to next message
Frédéric Ferrant is currently offline Frédéric FerrantFriend
Messages: 75
Registered: July 2009
Member
>you should be able to set a global variable then access that variable in
>the expression on the conditional highlighting using the mod code you
>provided

Thanks for your suggestion, David, but this doesn't work as I'd like
it to. I already had tried such a thing (the boolean test and the n %
2 test are the same).
I finally figured out a workaround, but it's a little tricky (I'm not
satisfied with it, allthough it works).

This is what I would like:
----------------------------
I would like to format the entire row background depending on the row
number. I tried doing this by selecting the row in the table (layout
mode), and setting a Highlight condition (n++ % 2 Equal 0) or (c=!c
Equal true).

Why it doesn't work:
------------------------
Unfortunately, the condition is checked for each cell in the row, and
not per row. Instead of having a table with even rows grey and odd
rows white, the table has cells alternatively grey and white on the
same row...
If you check the Highlight condition on each cell, it is indeed set to
the same condition as the one entered or the row.

This is what I had to do to get it to work:
------------------------------------------------
I removed the condition on each cell but the last one in the row.
The condition on the row is now: (n % 2 Equal 0), and the condition
on the last cell of the row is (n++ % 2 Equal 0).

Why I don't like that workaround:
---------------------------------------
The inconvenient of the workaround is that, if I add another data
column to the right of my row, I have to change the formatting code on
the last column... Thing which can easily be forgotten...
And the logic isn't to format the last cell differently than the
others, the logic is to format the entire row...

My questions:
---------------
1. Is it impossible to format rows? Does this in fact format the cells
composing the row...?
2. Is it possible to know the row number?
Re: Changing row formatting depending on the row number... [message #69804 is a reply to message #69758] Fri, 26 August 2005 14:09 Go to previous messageGo to next message
Michael McRoberts is currently offline Michael McRobertsFriend
Messages: 9
Registered: July 2009
Junior Member
You can get the row number using the expression "row[0]". I think the
feature you are looking for is called banding, but even with the row
number BIRT does not support real banding. See bug #102511 :
https://bugs.eclipse.org/bugs/show_bug.cgi?id=102511

You can use row[0] % 0 in a condition, but conditions are not applied to
rows, only to cells. Setting the background color of the cell is not the
same as setting the background of the row (see the examples attached to
the bug report) because of missing values and the different sizing of
the cells.

Michael
Re: Changing row formatting depending on the row number... [message #69828 is a reply to message #69758] Fri, 26 August 2005 14:12 Go to previous messageGo to next message
Michael McRoberts is currently offline Michael McRobertsFriend
Messages: 9
Registered: July 2009
Junior Member
You can get the row number using the expression "row[0]". I think the
feature you are looking for is called banding, but even with the row
number BIRT does not support real banding. See bug #102511 :
https://bugs.eclipse.org/bugs/show_bug.cgi?id=102511

You can use row[0] % 0 in a condition, but conditions are not applied to
rows, only to cells. Setting the background color of the cell is not the
same as setting the background of the row (see the examples attached to
the bug report) because of missing values and the different sizing of
the cells.

Michael
Re: Changing row formatting depending on the row number... [message #69946 is a reply to message #69758] Fri, 26 August 2005 20:21 Go to previous messageGo to next message
Mark Coggins is currently offline Mark CogginsFriend
Messages: 23
Registered: July 2009
Junior Member
Another way to skin the cat is to to have two rows and insert a grid into
each row. Each grid has the full set of data you want to show. You can turn
off and on the visibility of each grid with the visibility property. One is
set to hide when (row[0] % 2 == 0) is true and the other is set to hide when
(row[0] % 2 == 1) is true. The background color for one is set to gray and
the background for the other is left alone. You don't use the highlight
feature at all. I've attached a sample here.

It's definitely a hack since you have to duplicate so much info, though ...

Mark



Re: Changing row formatting depending on the row number... [message #70058 is a reply to message #69946] Mon, 29 August 2005 11:36 Go to previous message
Frédéric Ferrant is currently offline Frédéric FerrantFriend
Messages: 75
Registered: July 2009
Member
Mark and Michael, thanks for your help.
Thanks for the 'row[0]' tip to get the row number, it sure helps.
For the background formatting, the duplivcate grid seems to be quite
hacky indeed, I'll manage with a cell-formatting for the moment (and
see that the cells have the same height)...

Frédéric

On Fri, 26 Aug 2005 13:21:22 -0700, "Mark Coggins"
<mcoggins@actuate.com> wrote:

>Another way to skin the cat is to to have two rows and insert a grid into
>each row. Each grid has the full set of data you want to show. You can turn
>off and on the visibility of each grid with the visibility property. One is
>set to hide when (row[0] % 2 == 0) is true and the other is set to hide when
>(row[0] % 2 == 1) is true. The background color for one is set to gray and
>the background for the other is left alone. You don't use the highlight
>feature at all. I've attached a sample here.
>
>It's definitely a hack since you have to duplicate so much info, though ...
>
>Mark
>
>
Previous Topic:Opening pdf file
Next Topic:chart engine hangs
Goto Forum:
  


Current Time: Sun Nov 03 12:10:22 GMT 2024

Powered by FUDForum. Page generated in 0.03494 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top