Question

Can you please let me know how can I have 3rd level sub nodes in YUI treeview. I know how to do it for first level sub nodes. For example , for first level we have grandparents of family. in the next level we have parents. In the next we have grandchildren. It works for me till second level.i.e first level sub nodes. but for next level how should I set dynamic loading?

What I have done for first level sub nodes is associate callback to tree.

var tree=new YAHOO.widget.TreeView("tree");
var sUrl = "getJsonData-imp-ses";
var callback = {
    success : function(oResponse) {
        var array1 = YAHOO.lang.JSON.parse(oResponse.responseText);
        if (YAHOO.lang.isArray(array1)) {
            for (var i = 0, j = array1.length; i < j; i++) {
                var tempNode = new YAHOO.widget.TextNode(array1[i],    tree.getRoot(), false);
                console.log(tempNode);
            }
        }
        tree.draw();
        },
        failure : function(oResponse) {
        },
        timeout : 7000
};
YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);  

    tree.setDynamicLoad(function(node,fnLoadComplete){

        YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
            callback={
             success:{},
             failure:{},timeout:700
           };

)};

Now I want attach sub nodes to the 1st level sub nodes. I am using YUI 2.9.0. Can anyone please help?

Was it helpful?

Solution

See: http://yui.github.io/yui2/docs/yui_2.9.0_full/examples/treeview/dynamic_tree.html for a full example.

In your code, instead of using tree.getRoot() as the place to append the loaded nodes to, you can reference any other node to append them to, just like in the above example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top