Results 1 to 3 of 3

Thread: [solved] load node data of tree dynamically

  1. #1
    Ext User
    Join Date
    Nov 2009
    Location
    china
    Posts
    3

    Default [solved] load node data of tree dynamically

    i want to get first-stage child just when click the root node. then get the second-stage child when click the node of first-stage child. etc
    i've tried two ways,but they don't work.

    1. first way's code below

    Ext.onReady(function() {
    var tree = new Ext.tree.TreePanel({
    renderTo : Ext.getBody(),
    width : 200,
    height : 500,
    autoScroll : true,
    animate : true,
    loader : {
    dataUrl : 'get-nodes.php'
    },
    root : {
    text : 'Ext JS'
    }
    });
    });

    code in page get - nodes.php

    [{
    text : '2A folder Node',
    dataUrl : 'get-nodes1.php'
    }]

    this case load first-stage node is ok, then it's can't load the second node correctly when click the first-stage node.

    2. second way's code below

    Ext.onReady(function() {
    var tree = new Ext.tree.TreePanel({
    renderTo : Ext.getBody(),
    width : 200,
    height : 500,
    autoScroll : true,
    animate : true,
    loader : {
    dataUrl : 'a.jsp',// use for complete this request, the page a.jsp isn't exist.
    isLoaded : true,
    directFn : function() {
    Ext.Ajax.request({
    url : "get-nodes.php",
    success : function(resp) {
    tree.root
    .appendChild(resp.responseText);
    }
    });
    }
    },
    root : {
    text : 'Ext JS'
    }
    });
    });

    code in page get-nodes.php

    [{
    text : '2A folder Node',
    loader : {
    directFn : function() {
    Ext.Ajax.request({
    url : "get-nodes1.php",
    success : function(resp) {
    //node.appendChild(resp.responseText);
    }
    });
    }
    },
    }]

    on this case, it cant expand the child node,
    i think i don't understand directFn well.

  2. #2
    Ext User
    Join Date
    Nov 2009
    Location
    china
    Posts
    3

    Default directFn of TreeLoader

    anyone could show me how to use directFn of TreeLoader?
    or we can't send a specified request on each child's node?

  3. #3
    Ext User
    Join Date
    Nov 2009
    Location
    china
    Posts
    3

    Default we could try this, use baseParams of TreeLoader

    Ext.onReady(function() {
    var tree = new Ext.tree.TreePanel({
    renderTo : Ext.getBody(),
    width : 200,
    height : 500,
    autoScroll : true,
    id : "test",
    // useArrows: true,
    animate : true,
    loader : {
    dataUrl : 'get-nodes.php',
    baseParams : {
    category:"category"
    }
    },
    root : {
    text : 'Ext JS'
    }
    });
    });


    code in page get-nodes.php

    [{
    text : '2A folder Node',
    listeners : {
    beforeload : function(treeLoader) {
    treeLoader.getLoader().baseParams = {category:"changed"};
    }
    }
    }]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •