3.2.0

Highlight a Row in error

Hi,
I'm having difficulty doing a rather simple task.
I have a grid of 40rows X 20 columns.
One field on the row dictates whether its a row in error or not.
I'm looking so set the backgroud of any row in error to red.
I've tried using bits and pieces of previous posts but with no luck.

var colors = ["red", "blue", "green"];

obj.defineDataProperty("color", function(i){return colors[i]});

var row = new Active.Templates.Row;
row.setStyle("background", function(){
return this.getItemProperty("color");
});
obj.setRowTemplate(row);

This code does the necessary color setting but how do you specify which row??
I'm a bit confused??
Would anyone have an example of what I'm trying to do working??

Thanks to all
Brian.
September 7,
Lets say, you have your error field in column 4. Then your color function should look like

obj.defineDataProperty("color", function(i){return myData[i][4]});

'i' will give you row index.
Alex (ActiveWidgets)
September 7,
thanks for your reply,

sorry but still having trouble encorporating this. Could you look at the code below. Is this completely incorrect??
Would you have a quick example of this in action maybe??
thanks very much..

for( i = 0; i < disData.length; i++ )
{
if( disData[i][8] == '111')
{
alert('111 error');
var color = ["red"];

//myGrid.defineDataProperty("color", function(i){return colors[i]});
myGrid.defineDataProperty("color", function(i){return myData[i][4]});

var row = new Active.Templates.Row;
row.setStyle("background", function(){
return this.getItemProperty("color");
});

myGrid.setRowTemplate(row);

}
}
Brian.
September 8,

myGrid.defineDataProperty("color", function(i){
  if (disData[i][8]== "111"){
     return "red";
  }
  else {
     return "blue";
  }
}); 

var row = new Active.Templates.Row; 
  row.setStyle("background", function(){ 
  return this.getItemProperty("color"); 
}); 

myGrid.setRowTemplate(row);

Alex (ActiveWidgets)
September 11,
row.setStyle("background", function(){ 
  return this.getItemProperty("color"); 
});


In above code, what will 'this' refer to?

this.getDataProperty("text", row, col); //-- not giving correct result

But,
this.getDataProperty("text", col, row); //-- giving correct result

It would be great if someone can explain it.
Sudhaker Raj
September 13,
The code will be executed with row template object, so keyword 'this' refers to the row template. When you request a property of the data model (which is not available on 'row' level) the row template will redirect the call to the 'owner' template (in this case grid itself) adding its index as the second argument ('row' in your example) and shifting existing arguments one position to the right ('col'). So the call to row.getDataProperty(colIndex) will be redirected to grid.getDataProperty(rowIndex, colIndex).
Alex (ActiveWidgets)
September 19,

This topic is archived.

See also:


Back to support forum