Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
Searching an UltraWebGrid with Javascript
posted

I have created a search Javascript search function based on an Infragisitics sample and it is working well.  However the rows in my ultrawebgrid are formatted conditionally with different background colors if they meet certain critera.  When the search string is found it highlights the string in Green.  However when the user clicks find next it remains highlighted.  I would like the original highlighting restored but I keep getting Javascript Errors.  Here is my code:

<script language="javascript" type="text/javascript">

<!--

var oCell;

var oCellBackColor;

function Button1_onclick() {

var searchText=document.getElementById("TextBox1").value;

var grid=igtbl_getGridById("UltraWebGrid1");

var re = new RegExp( searchText , "gi");

if((document.getElementById("Button1").value=="Find"))

{

oCell = grid.find(re);

if(oCell != null)

{

oCell.setSelected(
true);

var rowid=oCell.Row.Id;

for(var i=0; i < oCell.Row.cells.length;i++)

{

 

oCellBackColor = oCell.Element.style.backgroundColor;    IT IS ERRORING HERE

oCell.Element.style.backgroundColor=
'Green';

}

 

document.getElementById(
"Button1").value="FindNext";

}

}

else if((document.getElementById("Button1").value=="FindNext"))

{

oCell.setSelected(
false);

oCell.Element.style.backgroundColor=oCellBackColor;

var oCell1= grid.findNext(re);

if(oCell1 != null)

{

oCell1.setSelected(
true);for(var i=0; i < oCell1.Row.cells.length;i++)

{

oCell1.Element.style.backgroundColor=
'Green';

}

oCell = oCell1;

}

}

}

 

// -->

</script>

 Any Help is much appreciated.