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.
Hi again seang,
I have implemented the functionality in the igTree. The findNodesByText and findImmediateNodesByText methods now match nodes that contain the given strings, not only exact matches. The methods are still case sensitive, however if you would like to make them case insensitive you can modify the :contains jQuery selector to be case insensitive as described in this article: http://css-tricks.com/snippets/jquery/make-jquery-contains-case-insensitive/
Let me know if you have any questions.
Your welcome, I'm just not built that way. Feedback is a must imo.
Thanks for the feedback! Usually people write us back only if the things don't work as they expected them to :)
the fix works well.
I use nuget for updates via the command prompt but i'd like to download the entire package and management it myself. Does nuget have a repository that I can download from the net? I just dont use it enough.
Hi Seang,
The fix would be available on NuGet with the next service release (we now have trial packages and free igGrid packages available on NuGet and we update them every service release). The next SR is scheduled to be the last week of June.
I hope this helps!