I tried using the findNodesByText to find a string contained in a node. To my great surprise it only search an exact match?
[I'm a node]
var nodes = this.treeIDMap.igTree( "findNodesByText", "I'm a" );// -> Found nothing
var nodes = this.treeIDMap.igTree( "findNodesByText", "I'm a node" );// -> Found the node
var nodes = this.treeIDMap.igTree( "findNodesByText", "node" );// -> Found nothing
Why would that be? So figuring this is only an exact match I'm trying to code a function to do what I need.
------------Here is one way to do it I guess ---------
var foundNodes = new Array(); filter = filter.toLowerCase(); findInObject = function( obj, prop, val )//go as deep as posible and find a match { if ( obj !== null && obj.hasOwnProperty( prop ) && obj[prop].toLowerCase().indexOf(val) > -1 ) { return obj; } else { for ( var s in obj ) { if ( obj.hasOwnProperty( s ) && typeof obj[s] == 'object' && obj[s] !== null ) { var result = findInObject( obj[s], prop, val ); if ( result !== null ) { return result; } } } } return null; } for ( var i = 0; i < this.treeData.length; i++ )//use the internal copy of the data to do the search and only modify the live { if ( findInObject( this.treeData[i], "ITEM", filter ) ) foundNodes.push( this.treeData[i] )//does the node have a match in it anywhere? } this.treeIDMap.igTree( { dataSource: foundNodes } ); this.treeIDMap.igTree( "dataBind" );
still would like it faster.
Hi seang,
It's great that you bring this up. I have been thinking about improving this functionality for a while. I will create a customer case for you and our developer support would log an issue which I can use to rework the functionality. My intention has been to make the search case-insensitive or to add a flag to make it case-sensitive if required. Is this what you have in mind? Its performance can be improved as well.
Thanks you for using the Infragistics forums!
yes case sensitive flag along with indexof searching or some other forum of text in text search. Thx for the effort, I'd like so see how much fast it would be compared to my method.