Home
Analytics
Crosstab alternate rows coloring
AshishK
I am developing a report on BIRT 2.3.0. I need to display the data with alternate rows displayed in different color.
So I applied the following logic:-
I selected the dimensions and under highlight property, i entered the following condition:-
row.__rownum % 2 Equal to 0
background color = RGB(220,220,220)
So that even number rows are of color RGB(220,220,220) and odd rows are white.
This logic works perfectly with table rows. But not with crosstabs.
Any idea?
Find more posts tagged with
Comments
mwilliams
Hi AshishK,
A table is made differently than a crosstab, so the same logic doesn't work to highlight rows for both. Check out the attached report design. The script in the crosstab's onCreate script should do what you're wanting. Let me know if you have questions. The report was created in 2.3.1, you may have to change the XML source version to match your version to run it.
nelatutaris
How do you modify your script in the crosstab's onCreate script so it works in a report that has three rows and three columns. I am getting gray white, gray white pattern in between the columns and rows and I need it to to be just in rows. Muchos Gracias,
Sanela
<method name="onCreate"><![CDATA[
/**
* Called when crosstab cell is being created.
*
*
@param
cellInst
* ICrosstabCellInstance
*
@param
reportContext
* IReportContext
*/
function onCreateCell( cellInst, reportContext )
{
if (cellInst.getDataValue("year") != null){
if (reportContext.getPersistentGlobalVariable(cellInst.getDataValue("year")) == null){
reportContext.setPersistentGlobalVariable(cellInst.getDataValue("year"),"01");
cellInst.getStyle().setBackgroundColor("RGB(220,220,220)");
}
else if(reportContext.getPersistentGlobalVariable(cellInst.getDataValue("year")) == "01"){
reportContext.setPersistentGlobalVariable(cellInst.getDataValue("year"),"1");
cellInst.getStyle().setBackgroundColor("RGB(220,220,220)");
}
else if(reportContext.getPersistentGlobalVariable(cellInst.getDataValue("year")) == "1"){
reportContext.setPersistentGlobalVariable(cellInst.getDataValue("year"),"0");
//cellInst.getStyle().setBackgroundColor("RGB(220,220,220)");
}
else{
reportContext.setPersistentGlobalVariable(cellInst.getDataValue("year"),"1");
cellInst.getStyle().setBackgroundColor("RGB(220,220,220)");
}
}
else{
if (reportContext.getPersistentGlobalVariable("null") == null){
reportContext.setPersistentGlobalVariable("null","1");
cellInst.getStyle().setBackgroundColor("RGB(220,220,220)");
}
else if(reportContext.getPersistentGlobalVariable("null") == "1"){
reportContext.setPersistentGlobalVariable("null","0");
//cellInst.getStyle().setBackgroundColor("RGB(220,220,220)");
}
else{
reportContext.setPersistentGlobalVariable("null","1");
cellInst.getStyle().setBackgroundColor("RGB(220,220,220)");
}
}
}]]></method>
nelatutaris
Hi Michael,
I've attached the report using your values in the format I need in order to illustrate the problem I am having(just in case I haven't explain things clearly before). Can you please help?
Thank you so much,
Sanela
mwilliams
Yep. Sorry for the delay, I was at JavaOne this week. I'm taking a look at it now!
mwilliams
Here ya go. This should do what you're wanting, or at least close to it, I think.
nelatutaris
Thank you so much for your hard work. I too was busy with other projects, so I didn't get to thank you immediately. But thank you so much for your help.
~Sanela
mwilliams
You're very welcome. Let us know whenever you have questions!
nelatutaris
Hi Michael,
I have another question and I really need your help. I have to create a drop-down list which I managed to create so far (see attached), but what I cannot figure out is how to FINISH MY DROP-DOWN LIST CODE, so as I pick one of the three values in the drop-down the user should have the choice of pulling this report in Actuate at 4 different levels:
1) Not Rounded
2) Rounded to the nearest Thousand
3) Rounded to the nearest Million
4) Rounded to the nearest Billion
In this case (attached) how would I divide #136 with the numbers in the drop-down list (1000, 1000000, 1000000000) as I chose any of them.
mwilliams
Meaning how would you reload the report with 136 divided by whichever value is selected? Let me know.
nelatutaris
Yes--how would I reload the report with 136 divided by whichever value is selected? Strange--I answered about a week ago to your reply but my reply got deleted. Please e-mail me when you get the answer at sanela.tutaris@bankofamerica.com
Thanks a lot,
Sanela
nelatutaris
Yes--how would I reload the report with 136 divided by whichever value is selected? Strange--I answered about a week ago to your reply but my reply got deleted. Please e-mail me when you get the answer at sanela.tutaris@bankofamerica.com
Thanks a lot,
Sanela
nelatutaris
I don't know what's going on with this BIRT exchange site, but it marks my previous reply as posted yesterday and I have posted it sometime last week. And a double reply??? Anyway Michael...please let me know if you can figure out this javascript code for dividing the cells by the values that are in the drop-down. Much appreciated!!!
mwilliams
Yeah. The site was down for maintenance for a bit last week, and some posts somehow got through, so they were lost in the shuffle. Sorry about that. I'll take a look, now.
nelatutaris
Thank you sooooooooooooooooooooooooooooooooooo much!!!!!
mwilliams
The way you're inserting the values into the drop down, it shows the values in the preview, but not in the web viewer or HTML. Not sure what the reason for that is. Is this happening the same for you? Once I get past that, I'll be able to get further on this.
mwilliams
Ah, wait. I switched browsers from firefox to IE. It works there. I think there was/is an issue with script tags and firefox with certain versions of BIRT and firefox. Alright, back at it!
nelatutaris
Thank you Michael. I know it's hard to figure this one out. Is there anything I could to for you to be of help to you?
mwilliams
Sorry, I didn't get to look at it again, until just now. Take a look at the attached example. I added a function in the text box where you have your drop down. It is called by the onChange of the drop down. Don't know if it was needed, but I also added a value property to your drop down populating function. I passed the value through to the function that reloads the parameters of the page. For you to run this from your designer, you'll need to change the string of parameters to match your parameters. The easiest way to do this is to set your designer to use external browsers and then copy from the '?' on and replace what is in my function, only leave the "&myParam=" part. If you're deploying it, just replace the string with "?__report=reportName.rptdesign&myParam=" Let me know if you have questions.
nelatutaris
Thanks Michael. Not sure what I am supposed to do from here on. Just wanted to let you know that I am trying to figure it out. So I am supposed to replace this part:
"?__report=C%3A%5CUsers%5Cmwilliams.HQ%5Cworkspace%5CBIRT+2_6_2%5CBIRT+2_6_2%5CCopy+of+drop-down+%281%29.rptdesign&__format=html&__svg=false&__locale=en_US&__timezone=US%2FIndiana-Starke&__masterpage=true&__rtl=false&__cubememsize=10&__resourceFolder=C%3A%5CUsers%5Cmwilliams.HQ%5Cworkspace%5CBIRT+2_6_2%5CBIRT+2_6_2&__dpi=96&-2127798691
With something like this on my side??? I am running this on iServer.
"?__report=
http://rcpa-uat.bankofamerica.com/iconsole/newrequest/do_executereport.jsp?__requesttype=immediate&__executableName=/Pillar3/",rptName,"&repositoryType=Enterprise&serverurl=http://lrche25472:8000&volume=CorporateTreasury
C:\Reports\BIRT\BA_Reports\Michael_drop-down_(1).rptdesign&
__format=html&
__svg=false&
__locale=en_US&
__masterpage=true
But this did not work. Not sure what I am missing.
mwilliams
You need to replace<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
?__report=C%3A%5CUsers%5Cmwilliams.HQ%5Cworkspace%5CBIRT+2_6_2%5CBIRT+2_6_2%5CCopy+of+drop-down+%281%29.rptdesign&__format=html&__svg=false&__locale=en_US&__timezone=US%2FIndiana-Starke&__masterpage=true&__rtl=false&__cubememsize=10&__resourceFolder=C%3A%5CUsers%5Cmwilliams.HQ%5Cworkspace%5CBIRT+2_6_2%5CBIRT+2_6_2&__dpi=96&-2127798691&myParam=
</pre>
<br />
with<br />
<br />
"EverythingAfterAndIncludingThe?InYourNormalURLToRunTheReport&myParam="<br />
<br />
Since I ran this from the designer, I just copied the URL that the designer uses. That's why my parameter string is so long.<br />
<br />
Hope this helps.
fabulon12
Thank you for this crosstab alternate highlight sample !!!<br />
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="58341" data-time="1261431220" data-date="21 December 2009 - 02:33 PM"><p>
Hi AshishK,<br />
<br />
<br />
A table is made differently than a crosstab, so the same logic doesn't work to highlight rows for both. Check out the attached report design. The script in the crosstab's onCreate script should do what you're wanting. Let me know if you have questions. The report was created in 2.3.1, you may have to change the XML source version to match your version to run it.<br /></p></blockquote>
mwilliams
You're welcome! Let us know whenever you have questions!
Tahir Yasin
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="83845" data-time="1318008531" data-date="07 October 2011 - 10:28 AM"><p>
Here ya go. This should do what you're wanting, or at least close to it, I think.
<br /></p></blockquote>
<br />
<br />
Thanks for the script, I'm new to Birt, can you please guide me how to use this script?
mwilliams
Take a look at this example, instead. It should be much easier. All you need to look at is the highlight script for the row dimension cell (not the data element) and for the measure cell. The highlight rule section is in the property editor. You should be able to copy this exact code into your report and it should work. Let me know if you have further questions. This report was made in 3.7.2.
Tahir Yasin
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="114844" data-time="1362589083" data-date="06 March 2013 - 09:58 AM"><p>
Take a look at this example, instead. It should be much easier. All you need to look at is the highlight script for the row dimension cell (not the data element) and for the measure cell. The highlight rule section is in the property editor. You should be able to copy this exact code into your report and it should work. Let me know if you have further questions. This report was made in 3.7.2.<br /></p></blockquote>
<br />
<br />
Thank you so much!
Tahir Yasin
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="114844" data-time="1362589083" data-date="06 March 2013 - 09:58 AM"><p>
Take a look at this example, instead. It should be much easier. All you need to look at is the highlight script for the row dimension cell (not the data element) and for the measure cell. The highlight rule section is in the property editor. You should be able to copy this exact code into your report and it should work. Let me know if you have further questions. This report was made in 3.7.2.<br /></p></blockquote>
<br />
<br />
I've changed the orientation of cross-tab to Horizontal, your script highlights alternate columns not rows in this scenario, please guide me how to overcome this problem?
mwilliams
The crosstab in the example I posted is of horizontal orientation. Can you make the changes you're making to the report I attached an re-attach it, so I can see what you've done and what you're seeing. Thanks!
esram
<blockquote class="ipsBlockquote" data-author="mwilliams" data-cid="83844" data-time="1318006037"><div><p>Yep. Sorry for the delay, I was at JavaOne this week. I'm taking a look at it now! <img src='
http://www.birt-exchange.org/org/forum/public/style_emoticons/default/smile.gif'
alt='Posted Image' class='bbc_img' /></p></div></blockquote><p>Hi mwilliams,</p><p> </p><p>I was looking for a solution for the alternative row shading in cross tabs I came across to your article but couldn't see the example? Could you please share it once more again?</p><p> </p><p>Thanks in advance.</p><p> </p><p>Regards,</p>
mwilliams
<p>It seems my example disappeared. That is odd. What is your BIRT version? I'll attach a new one.</p>
esram
<p>Hi Michael,</p><p> </p><p>Thank you for your prompt reply. Actually I use Actuate BIRT for reporting. </p>