:: Forum >>

Help changing row color

I have code that will search for a certain string in a specified column and change the color of the row in where it is found. That works fine. I also have a reset button that should set the line back to its old color, for some reason that does not work. here is the code:

function refreshTable(){
var max = obj.getRowProperty("count");
for (i=0; i<max; i++){
//#myGrid .aw-alternate-even {background: #fff;}
//#myGrid .aw-alternate-odd {background: #eee;}
// manually set column-0 background-color
//obj.getCellTemplate(0).setStyle("background-color", "yellow");

if (Mod(i,2)== 0){
obj.getRowTemplate(i).setStyle("background","white");
//alert('set color row '+i);
} else {
obj.getRowTemplate(i).setStyle("background","lightblue");
}
}
obj.refresh();
//obj.request();

}

// start searching at next position and cycle at end
function find(startIndex){
var col = document.listForm.findSelect.value;
var findString = document.getElementById("findText").value;

var max = obj.getRowProperty("count");
pos=nextPos(startIndex);
var found = -1;
for (i=pos-1; i<max; i++){
//var index = obj.getRowProperty("value", i); obj.getCellValue(i,row)
var cellStr = obj.getCellValue(col,i); // get the string in the cell
if (cellStr.indexOf(findString) >= 0){
//obj.getCellTemplate(i).setStyle("background-color", "yellow");
obj.getRowTemplate(i).setStyle("background","red");
found = i;
//return i;
}
}
if (found == -1){
var cellNbr = parseInt(col)+1;
alert('Value not found in column '+ cellNbr);
}
else {
obj.refresh();
}
}

// returns next position and cycle at end.
function nextPos(index){
var max = obj.getRowProperty("count");
if (index<0 || index>=(max - 1)){
return 0;
}
return index + 1;
}
ShepherdOwner
Wednesday, January 11, 2006
Instead of messing with Javascript to change the background color, why don't you simply change the class of the cell? Then you can simply change the class back to it's original setting. This is a much cleaner way to do it.
Jim Hunter
Wednesday, January 11, 2006
Jim,

Can you please give me the lines of code to do this? Thank you very much. It still seems like my code should work but that activewidgets has an issue about changing the color multiple times.
ShepherdOwner
Wednesday, January 11, 2006
I think I will change from AW.Grid.Extended to AW.UI.Grid. I don't see these problems when I use AW.UI.Grid. Alex, what functions don't I have with AW.Grid.Extended ?
ShepherdOwner
Wednesday, January 11, 2006

This topic is archived.


Back to support forum

Forum search