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

cancel NodePopulating?

2 Answers 46 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Andrew Johns
Top achievements
Rank 1
Andrew Johns asked on 08 Jul 2009, 03:16 PM
not even sure I want to actually cancel the nodepopulating event yet, but I'll explain what I'm attempting:

I have a radtreeview, with it's nodes being populated by a webservice when expanded.  As it turns out, one of the nodes has a LOT of children, and even taking into consideration an extra level of nodes, to perhaps break the subnodes down by alphabetical order, it doesn't look like the most usable way of selecting nodes under that category, not to mention very slow to return so many nodes.

So, what was considered is something along the lines of canceling the particular nodePopulating event (although I guess the better approach is to change the TreeNodeExpandMode for that node in the first place - I think I just answered my own question), and instead of loading the nodes instantly, display a textbox, where the user can start typing the first letters of the required child node, at which point the nodes under that category will filter based on the user's text entry.  I can imagine this being an ajax style predictive text box, but perhaps this isn't that important - the key thing is not actually populating children for this node until the user has entered some text into a textbox to filter the list.

Sound possible?

2 Answers, 1 is accepted

Sort by
0
Andrew Johns
Top achievements
Rank 1
answered on 08 Jul 2009, 05:04 PM
Ok, what I've managed to do so far is modify my nodePopulating function, so that if a particular  condition is met, the node becomes a client side rather than WebService expand mode.

function nodePopulating(sender, eventArgs) {

    var node = eventArgs.get_node();
    var context = eventArgs.get_context();      

    nodevalue = node.get_value().split("|");
   
    context["tagType"] = nodevalue[0];
    context["tagID"] = nodevalue[1];

    if (context["tagType"] == "ATagType") {
        var newnode = new Telerik.Web.UI.RadTreeNode();
        newnode.set_text("test");
        node.set_expandMode(Telerik.Web.UI.TreeNodeExpandMode.ClientSide);
        node.expand();
        eventArgs.set_cancel(true);
    }     
}

Which creates a new node on the fly, with text "test".  My question now is: This page (http://www.telerik.com/help/aspnet-ajax/tree_nodescontrols.html) suggests it's possible to put a textbox into a node, albeit this example is server side.  Can it be done using javascript, or do I abandon this now and switch to doing it using a server side postback when this node is clicked, and then populate the textbox that way?

The end result is that the textbox (and "go" button) will then attempt to retrieve child nodes based on the search criteria, using the original webservice I set up originally.
0
Atanas Korchev
Telerik team
answered on 09 Jul 2009, 08:43 AM
Hi Andrew Johns,

You can inject arbitrary html in the node element, however it would disappear after postback. Anyway here is some sample code to get you started:

var input = document.createElement("input")

var node = $find("tv1").get_nodes().getNode(0);
node.get_contentElement().appendChild(input);

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TreeView
Asked by
Andrew Johns
Top achievements
Rank 1
Answers by
Andrew Johns
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or