Reset the row setStyle to allow a search in Grids
I have a grid that I am cycling through the rows looking for a searchterm...
BUT, I just want to highlight the rows... which means that searching for a different key means changing the external textbox and clicking the search button again.
So, here's my searching function.... how can I RESET the rows to their CSS alternating colors/backgrounds after this runs? (otherwise you have to completely redo the grid to get rid of any previous searches)
BUT, I just want to highlight the rows... which means that searching for a different key means changing the external textbox and clicking the search button again.
So, here's my searching function.... how can I RESET the rows to their CSS alternating colors/backgrounds after this runs? (otherwise you have to completely redo the grid to get rid of any previous searches)
Button_Items_Search.onClick=function(){
var searchText='';
var found=false;
var count=0;
var searchText = [null,null,null];
if(Input_Items_Search_UPC.getControlText().length>1) {
searchText[0]= new RegExp(Input_Items_Search_UPC.getControlText().replace("\"","''"),"i");
}
if(Input_Items_Search_SKU.getControlText().length>1) {
searchText[1]= new RegExp(Input_Items_Search_SKU.getControlText().replace("\"","''"),"i");
}
if(Input_Items_Search_Description.getControlText().length>1) {
searchText[2]= new RegExp(Input_Items_Search_Description.getControlText().replace("\"","''"),"i");
}
for(var i=0; i<Grid_Items_Items.getRowCount(); i++) {
for(var j=0; j<searchText.length; j++) {
if(searchText[j]!=null) {
var tmp=Grid_Items_Items.getCellData(j,i);
if(searchText[j].test(tmp)) {
Grid_Items_Items.getTemplate("row", i).setStyle("color", "white");
Grid_Items_Items.getTemplate("row", i).setStyle("background", "blue");
found=true;
count++;
}
}
}
}
if(!found) alert('Not Found');
else alert('Found '+count+' entries');
}
John Mason
December 6,