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;
}
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
January 11,