3.0.5

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
February 11,
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
February 14,
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
February 15,
thanks.. it's helpful
krvmla
February 16,
where do you place this code?
pete
August 15,

This topic is archived.

See also:


Back to support forum