3.2.0

Highlighting letters in the Grid challenge

Dear All,

I am performing an incremental search on the grid and am able to highlight the column i am performing the search on.

This is the code for highlighting based on a row value. However i want to highlight just the letter which i typed. How do i do that. I am populating the grid using XML dynamically.

var stringToFind = document.getElementById(searchIn).value.toUpperCase();

var xmlDoc = table.getXML();

var nodes = xmlDoc.selectNodes("//document/report/" + colToBeSearched);
var matchingRows = new Array();
// Retreive the Column selected to search on
var colIndex = document.getElementById('listColumns').selectedIndex;
//alert(colIndex);
for(i=0;i<nodes.length;i++)
{
var s = nodes[i].text.toUpperCase();
if (s.match(stringToFind))
{
matchingRows.push( i );

}
if(!s.match(stringToFind))
{
obj.getColumnTemplate(colIndex + 1).setStyle("color", "blue");
}
else
{
obj.getColumnTemplate(colIndex + 1).setStyle("color", "black");
}
}

obj.setRowCount(matchingRows.length);
obj.setRowValues(matchingRows);

obj.refresh();

Regards,
Lols
Lols
February 14,
Don't think you could highlight just what you typed unless you modify the text within the data with a SPAN or something which you could style with your colors.

EX.
You search for "Street"
Your particular column has
"12345 This Street"
To be able to highlight only what you typed
"12345 This <span class="highlight">Street</span>"

Otherwise there is no way to change just for that text.

You may want to add something like
s.replace(stringToFind, "<span class=\"highlight\">"+stringToFind+"</span>").
Tony (www.FriendsOfAW.com)
February 14,

This topic is archived.

See also:


Back to support forum