Home
Analytics
cross tab highlight rules..
soft
Hi,
I am new in birt 2.3 reporting. I want to know how i can use highlight rules in cross tab. For example in crosstab when result display it show one line background color blue and second line color red.
Thanks
soft
Find more posts tagged with
Comments
zoso
I'm not expert, but you can see:<br />
<a class='bbc_url' href='
http://www.birt-exchange.com/devshare/designing-birt-reports/231-style-enhancements-birt-2-2-1-tutorial-series/#'>http://www.birt-exchange.com/devshare/designing-birt-reports/231-style-enhancements-birt-2-2-1-tutorial-series/#</a><br
/>
<a class='bbc_url' href='
http://www.birt-exchange.com/devshare/designing-birt-reports/232-report-design-for-style-enhancements-birt-2-2-1-tutorial-series/'>http://www.birt-exchange.com/devshare/designing-birt-reports/232-report-design-for-style-enhancements-birt-2-2-1-tutorial-series/</a><br
/>
bye
soft
Thanks. This highlight rules for table while i want to know highlight rules for cross tab. Can some one help me..
Thanks
mwilliams
Hi Soft,
Crosstabs are done cell by cell, not row by row, so there's no highlighting rule that you can do to highlight every other row. You'll have to get the highlighting done on every other cell by doing something like the following. You will come into problems when the cell is repeated across multiple columns. You'll have to come up with a check to know when you're starting another column dimension. I'll see if I can find something to check that, but this should at least get you started. Make sure you use the ElementID for the cell, not the data element in the cell.
i = 0;
function onCreateCell( cellInst, reportContext )
{
if (cellInst.getCellID() == 72){
if (i == 0){
cellInst.getCellID();
cellInst.getStyle().setBackgroundColor"#0000FF");
i=1;
}
else {
cellInst.getStyle().setBackgroundColor("#FF0000");
i=0;
}
}
}
mwilliams
It looks like the rows are done from left to right...not top to bottom, so the check will have to be done with either the row dimension or if you know how many columns you're gonna have, you could run a loop and color them that way.
Hope this helps.
soft
Thanks Michael ,
its work nice to change cell color. but i want to chnage row. cell number is based on parameter value. I cann't account cell number. Is there any way to get total cells or get next row value .
mwilliams
Soft,
To my knowledge, there is no way to highlight based on rows with crosstabs.
Lived_Ip
It is certainly possble to highlight cross tab rows.
You'll first need to figure out how many columns are being created....For your header row that repeats and defines how many columns there are, update a global variable to calculate the total number of columns in the onCreate() function:
var count = new Number(reportContext.getPersistentGlobalVariable("TotalColumnCount"));
count++;
reportContext.setPersistentGlobalVariable("TotalColumnCount", count.toString());
Now, in the onCreateCell() function in the cross tab script, check the cell id to see if its a cell you want to highlight, then check against a cell counter to see whether you are on an even row or an odd row(since we know the total # of columns and the # of cells rendered, we can tell which row we're on):
function onCreateCell( cellInst, reportContext )
{
//check to see if this cell id is a cell we want highlighted
if(cellInst.getCellID() == 65) {
//calculate the row we're on
if(parseInt(reportContext.getPersistentGlobalVariable("CurrentCellCount")/reportContext.getPersistentGlobalVariable("TotalColumnCount")) % 2 == 0) {
cellInst.getStyle().setBackgroundColor("#FFECCC");
} else {
cellInst.getStyle().setBackgroundColor("#C7D6FC");
}
//finally, increment the cell count
var count = new Number(reportContext.getPersistentGlobalVariable("CurrentCellCount"));
count++;
reportContext.setPersistentGlobalVariable("CurrentCellCount", count.toString());
}
}
The code above hasn't been tested, but should get someone on the right track.
SoftOcean
Hi Lived_Ip,
Thanx for replying. I am trying to use you code but i didn't get the proper result. As you mentioned this code to use on create method.
var count = new Number(reportContext.getPersistentGlobalVariable("TotalColumnCount"));
count++;
reportContext.setPersistentGlobalVariable("TotalColumnCount", count.toString());
I used it but it doesn't return total number of coloumns. can you please explain more how i can count total coloumn in cross tab.
Thanx
Soft