:: Forum >>

How to change row background color in gird based on a column value: reading data from csv text file..

Hello,
I am reading data from csv text file and displaying it in the grid...
i need to change the row background color based on a column value in the row of the text file..

Can someone help me with this please-- urgent...........

Thanks for the great Support..

krvmla
Friday, February 11, 2005
I am using a two-dimensional javascript array named rsMP as my data source. I modified the example for alternating row colors to change the background color of a row based on the value of the 7th column in that row. I had problems retrieving the text from that column, so I just accessed the data source that supplies the columns value. The data value happens to be a color value that I just use as the background color

var obj = new Active.Controls.Grid;
obj.setRowCount(rsMPr);
obj.setColumnCount(7);
obj.setRowHeaderWidth("0px");
obj.setDataText(function(i, j){return rsMP[i][j]});
obj.setColumnText(function(i){return rsMPcolumns[i]});

var alternate = function(){
var rwn = this.getProperty("row/order");
var color = rwn % 2 ? "#EEEEEE" : "#FFFFFF";
var colorVal = rsMP[rwn][6];
return (colorVal!='') ? colorVal : color;
}
var row = new Active.Templates.Row;
row.setStyle("background", alternate);
obj.setTemplate("row", row);
document.write(obj);
Swick
Monday, February 14, 2005
i use this function:
function myColor(){ var value = this.getItemProperty('value'); return value == '' ? 'yellow' : 'white';}\n";
obj.getColumnTemplate(3).setStyle('background-color', myColor);\n";
hope useful
roberto
Tuesday, February 15, 2005
thanks.. it's helpful
krvmla
Wednesday, February 16, 2005
where do you place this code?
pete
Monday, August 15, 2005

This topic is archived.


Back to support forum

Forum search