Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
table-row -> onCreate -> set row style?
roopurt81
Greetings,
I have a style in my report named "highlight-table-row." In my detail row's onCreate() handler I'd like to apply this style via the style name. I was thinking something like:
// this is the table row
this.setNamedStyle( "highlight-table-row" );
I can't seem to find any method that would accomplish this.
The best I can do is:
this.style; // IScriptStyle instance, which lets me look at all of the properties
I tried looking around in the object returned by:
reportContext.getDesignHandle();
There's some hope there because I can find report styles by name. But then I'd have no idea what's the best way to apply the styles to the row.
Any help is appreciated!
Find more posts tagged with
Comments
roopurt81
I thought I'd post a reply with a bit more context and what I'd settled on since I can't figure out how to do exactly what I want.<br />
<br />
I'm creating a set of generic reports for a new product. I'm using a report library to store the report styles and themes so I can easily change all reports if necessary. In my library I have a style named "highlight-table-row" and the only property that is not default is backgroundColor.<br />
<br />
One of my reports is a listing of transactions sorted by an associated vehicle. The report is much easier to read if alternating vehicles are highlighted. Ideally when it was time to highlight a row, I would have liked to say:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>row.setStyleName( "highlight-table-row" );</pre>
But there is no such method. A highlight rule may have worked because you can set a style for a highlight rule. However my logic for determining the highlight occurs in table-row.onCreate() and the highlight rule is applied <em class='bbc'>before</em> my logic occurs, so the row highlights end up incorrect.<br />
<br />
Anyways, here is what I came up with.<br />
<br />
In my report's initialize() event:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>// Set tracking object
g_tracker = {
// Highlight flag. True if highlight is applied, false otherwise.
highlight : true,
// Current value from column that is being watched.
value : null,
// Name of the column to watch in the table.
column_name : "vehicle_cd",
// The style to apply when highlighting is in effect. Change the string
// argument to the name of the appropriate style.
style : reportContext.getDesignHandle().findStyle( "highlight-table-row" )
};
/**
* Call this in table detail onCreate(), as such:
* table_row_create( this ); // this is the table row
*
*
@param
table-row
*/
function table_row_create( row ) {
// Row's data
data = row.getRowData();
// The value for this row
value = data.getColumnValue( g_tracker.column_name );
// Do not attempt to use !== or != for this comparison.
// It compares the objects and not their values!
if( BirtComp.notEqual( value, g_tracker.value ) ) {
g_tracker.highlight = ! g_tracker.highlight; // Toggle highlight value
}
if( g_tracker.highlight === true ) {
// TODO ADD LINES FOR ADDITIONAL PROPERTIES IF NECESSARY
// UNTIL BIRT HAS A SETSTYLE( “NAME” ) METHOD.
row.getStyle().setBackgroundColor( g_tracker.style.getBackgroundColor().getStringValue() );
}
g_tracker.value = value;
}</pre>
<br />
And in the table-row.onCreate() event:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>table_row_create( this );</pre>
<br />
If anyone can offer any pointers or tips so that I can achieve my goal, I'd still appreciate it.