Home » Archived » BIRT » onRender
onRender [message #15381] |
Mon, 07 March 2005 22:42 |
Eclipse User |
|
|
|
Originally posted by: mbatchelor.no_s_p_a_m.pentaho.com
Hey all,
I'm looking for a simple example of using script to do some basic
conditional formatting. By looking in the doc, it claims I can do it. There
are no examples however.
For a simple test, I'm simply trying to look at the contents of a column,
and based on the value, change the background and foreground color of the
data.
For simplicity, I've got a simple integer column and a string column.
If the value of the target cell is between 0 and 13, color the cell green.
Between 14 and 27, yellow, and greater than or equal to 28 red.
Again, this is merely a simple expression, but I can't seem to find what
properties on which objects to set. I assume (based on the scant
documentation) that I'm interested in doing it in the onRender.
Additionally, I believe I want to refer to ItemState.row to obtain the
value.
Are there any examples of this available?
Thanks,
Marc
|
|
|
Re: onRender [message #15417 is a reply to message #15381] |
Mon, 07 March 2005 23:06 |
Eclipse User |
|
|
|
Originally posted by: mbatchelor.no_s_p_a_m.pentaho.com
As a side note, I've also been trying to play with a highlight rule. But
again, in the absense of some examples, I'm not sure which properties I can
manipulate on which objects.
Thanks again,
Marc
|
|
|
Re: onRender [message #15546 is a reply to message #15381] |
Tue, 08 March 2005 03:31 |
Stanley Wang Messages: 81 Registered: July 2009 |
Member |
|
|
Hi, Mark,
ElementState objects have not been implemented yet, but highlight rules
have.
Even without ElementState objects, you should be able to achieve a lot of
special effects that are traditionally achieved through scripting.
The following paragraph from the updated ROM scripting spec (not public
yet) might clarify some of your confusions:
One design goal of BIRT scripting is to allow most tasks that are
traditionally performed through scripting to be achieved through element
expressions (except for scripted data set). Some examples are given below:
Formatting based on data type. A BIRT style defines three format
strings, namely numberFormat, datetimeFormat and stringFormat, to
automatically choose the right format string based on data type.
Display negative numbers in absolute values with () around. This is
achieved by specifying subpatterns in format string, such as
"#,##0.0#;(#,##0.0#)".
Display negative numbers in red color. This is achieved through
highlight rules.
Display first name concatenated with last name in a single data item; or
display row.price * row.quantity if the product is less than $1M, or
row.price * row.quantity * 90% if the product is larger than $1M. Both can
be easily done using value expressions.
Display Excellent, Very Good, Good, Fair and Poor based on
test scores and a set of range rules. This can be achieved using map
rules.
Display correlated values in another data item. Assume that one column
(with name A) in a table displays the order size (row.orderSize), and
another column (with name B) displays the order size as a percentage of
the total order size. It is recommended that Bs value expression be
written as row.orderSize * 100 / totalOrderSize, instead of
container.B.value * 100 / totalOrderSize. That is, references to other
elements should be avoided. In fact, if the second column is to be
searched or extracted, a computed column is recommended.
Hide two columns if the viewer is not from a management team. This can
be achieved using visibility expression.
Stanley Wang
BIRT Engine
Marc Batchelor wrote:
> Hey all,
> I'm looking for a simple example of using script to do some basic
> conditional formatting. By looking in the doc, it claims I can do it. There
> are no examples however.
> For a simple test, I'm simply trying to look at the contents of a column,
> and based on the value, change the background and foreground color of the
> data.
> For simplicity, I've got a simple integer column and a string column.
> If the value of the target cell is between 0 and 13, color the cell green.
> Between 14 and 27, yellow, and greater than or equal to 28 red.
> Again, this is merely a simple expression, but I can't seem to find what
> properties on which objects to set. I assume (based on the scant
> documentation) that I'm interested in doing it in the onRender.
> Additionally, I believe I want to refer to ItemState.row to obtain the
> value.
> Are there any examples of this available?
> Thanks,
> Marc
|
|
| |
Re: onRender [message #15608 is a reply to message #15576] |
Tue, 08 March 2005 03:49 |
Eclipse User |
|
|
|
Originally posted by: mbatchelor.no_s_p_a_m.pentaho.com
Stanley,
Thanks for your reply. Yes, I have a data item bound to the data column.
However, I find nothing like "Add/Edit highlight rule". Here's how I put
this thing together:
a. Created new report, created a datasource and a simple dataset. When I
created the report, I chose a simple report template.
b. On the report design, I've assigned each column to a cell in the detail
area of the simple report.
OK - so now, at this point, I can preview the report, and see data. To
perform the conditional formatting, I've tried selecting the column and gone
to the code tab. On the code tab, I can select the highlightTestExpr
expression, but I have no examples of the script I can use for conditional
formatting.
Can you give me a hint?
Thanks,
Marc
"Stanley Wang" <swang@actuate.com> wrote in message
news:d0j6k4$um8$1@www.eclipse.org...
> Marc,
>
> You are right to use highlight rules. I assume that you have a data item
> that binds to a DB column. Say the column name is A in DB. You need to
> create 3 highlight rules on the data item. You use row.A to refer to the
> value from DB, instead of ElementState.row. The Add/Edit highlight rule UI
> is fairly intuitive for you to add new highlight rules.
>
> Stanley Wang
> BIRT Engine
>
>
> Marc Batchelor wrote:
>
> > As a side note, I've also been trying to play with a highlight rule. But
> > again, in the absense of some examples, I'm not sure which properties I
can
> > manipulate on which objects.
>
> > Thanks again,
>
> > Marc
>
>
|
|
|
Re: onRender [message #15671 is a reply to message #15608] |
Tue, 08 March 2005 04:44 |
Stanley Wang Messages: 81 Registered: July 2009 |
Member |
|
|
Marc,
Not sure if you have done so, but when you design a report, try to switch
to report design perspective. Also, make sure that the BIRT property
editor view (Show View-->Other-->BIRT-->Property Editor) is active. There
are three tabs at the bottom of the property editor view if you put focus
on a data item. The rightmost one says "highlights".
Hope this helps.
Stanley Wang
BIRT Engine
Marc Batchelor wrote:
> Stanley,
> Thanks for your reply. Yes, I have a data item bound to the data column.
> However, I find nothing like "Add/Edit highlight rule". Here's how I put
> this thing together:
> a. Created new report, created a datasource and a simple dataset. When I
> created the report, I chose a simple report template.
> b. On the report design, I've assigned each column to a cell in the detail
> area of the simple report.
> OK - so now, at this point, I can preview the report, and see data. To
> perform the conditional formatting, I've tried selecting the column and gone
> to the code tab. On the code tab, I can select the highlightTestExpr
> expression, but I have no examples of the script I can use for conditional
> formatting.
> Can you give me a hint?
> Thanks,
> Marc
> "Stanley Wang" <swang@actuate.com> wrote in message
> news:d0j6k4$um8$1@www.eclipse.org...
>> Marc,
>>
>> You are right to use highlight rules. I assume that you have a data item
>> that binds to a DB column. Say the column name is A in DB. You need to
>> create 3 highlight rules on the data item. You use row.A to refer to the
>> value from DB, instead of ElementState.row. The Add/Edit highlight rule UI
>> is fairly intuitive for you to add new highlight rules.
>>
>> Stanley Wang
>> BIRT Engine
>>
>>
>> Marc Batchelor wrote:
>>
>> > As a side note, I've also been trying to play with a highlight rule. But
>> > again, in the absense of some examples, I'm not sure which properties I
> can
>> > manipulate on which objects.
>>
>> > Thanks again,
>>
>> > Marc
>>
>>
|
|
|
Goto Forum:
Current Time: Sat Oct 19 18:01:15 GMT 2024
Powered by FUDForum. Page generated in 0.02471 seconds
|