Search code examples
eclipsefunctionreportbirteventhandler

Access datasource in eventhandlers


The below code is generating errors:

Initialize:

 var firstC = ["AUD","ZAR"];
var secondC= ["AUD","BRL","CAD","USD"];


function colorG(item, col, row){

var currency = firstC[col] + "-"+ secondC[row];
if(verifyCurrency(currency)==true)

item.getStyle().backgroundColor="green";
}

function verifyCurrency(currency)
{

if(this.getRowData().getExpressionValue("row[digital]").indexOf(currency)!=-1)
return true;
else return false;
}

cell:

colorG(this,1,0);

In which phase do I have to place verifyCurrency so that it will work?


Solution

  • Your assumption about "this" in your verifyCurrency function is wrong. I don't know Javascript good enough to tell you more about this, but I think that "this" is always defined inside a function. But it is not pointing to your item instance!

    To fix this (no pun intended), pass the item as an argument to your verifyColor function.