This is a migrated thread and some comments may be shown as answers.

get_allNodes() returning empty nodes in chrome

1 Answer 88 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Phani Alla
Top achievements
Rank 1
Phani Alla asked on 07 Feb 2011, 11:42 PM
Hi There, 

I have a treeview that has around 1100 nodes, I've added a type ahead search for the treeview using onClientKeyPressingHandler on a textbox. I loop through all the nodes of the treeview returned by the get_allNodes() method and look for match by getting the node text using get_text(). This is working well in IE, but in Chrome, the get_allNodes is returning some empty nodes which hence are not being returned as matches, any suggestions/ideas on what I could be doing wrong? I'm including my javascript code i'm using to search. 

function FindAppendages(treeview, textSearch) {
 
    var radtree = $find(treeview);
 
    var nodes = radtree.get_allNodes();
 
    var subsetArray = new Array();
 
    for (var i = 0; i < nodes.length; i++) {
 
        var oNode = nodes[i];
 
        if (oNode.get_text().toLowerCase().match(textSearch.value.toLowerCase()) != null) {
 
            oNode.set_visible(true);
 
            var parent = oNode.get_parent();
 
            if (parent != null) {
 
                parent.set_visible(true);
 
                if (parent._text != undefined) {
 
                    subsetArray.push(parent.get_text());parent.set_expanded(true);
 
                }
 
            }
 
            parent = parent.get_parent();
 
            if (parent != null) {
 
                parent.set_visible(true);
 
 
 
                if (parent._text != undefined) {
 
                    subsetArray.push(parent.get_text());parent.set_expanded(true);
 
                }
 
            }
 
            parent = parent.get_parent();
 
            if (parent != null) {
 
                parent.set_visible(true);
 
 
 
                if (parent._text != undefined) {
 
                    subsetArray.push(parent.get_text());parent.set_expanded(true);
 
                }
 
            }
 
            parent = parent.get_parent();
 
            if (parent != null) {
 
                parent.set_visible(true);
 
 
 
                if (parent._text != undefined) {
 
                    subsetArray.push(parent.get_text());parent.set_expanded(true);
 
                }
 
            }
 
        }
 
        else {
 
            var match = false;
 
            for (var j = 0; j < subsetArray.length; j++) {
 
                if (oNode.get_text() == subsetArray[j])
 
                    match = true;
 
            }
 
            if (!match)
 
                oNode.set_visible(false);
 
        }
 
    }
 
}


Thanks,
Phani

1 Answer, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 11 Feb 2011, 09:57 AM
Hi Phani Alla,

I wasn't able to reproduce the problem you experience. I have tested one of our demos (http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/checkboxes/defaultcs.aspx) using the following in the console:
var tree = $find("RadTreeView1");
 
var nodes = tree.getAllNodes();
 
$telerik.$(nodes).each(function(){console.log(this.get_text());});
And all the nodes names were displayed:
Software
Business & Office
Database
Networking
Presentation
Project Management
Reports
Spreadsheet
Word Processing
Books
Arts
Biographies
Children's Books
Computers & Internet
Cooking
History
Fiction
Mystery
Nonfiction
Romance
Science Fiction
Travel
Music
Alternative
Blues
Children's Music
Classical
Country
Dance
Folk
Hard Rock
Jazz
Soundtracks
Movies
Action
Animation
Classics
Comedy
Documentary
Drama
Horror
Musicals
Mystery
Westerns


Regards,
Nikolay Tsenkov
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
TreeView
Asked by
Phani Alla
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Share this question
or