:: Forum >>

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.
Tuesday, September 7, 2004
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)
Tuesday, September 7, 2004
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.
Wednesday, September 8, 2004

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)
Saturday, September 11, 2004
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
Monday, September 13, 2004
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)
Sunday, September 19, 2004

This topic is archived.


Back to support forum

Forum search