[CLOSED] Trigger the loading of TreePanel´s data

  1. #1

    [CLOSED] Trigger the loading of TreePanel´s data

    Hi folks, in the following example the load of root node´s content occurs when it is expanded. If i set the rootVisible property to false the "root" nodes are loaded automatically. I would like to know whether it´s possible to control the load of "root" nodes when rootVisible property is set to false. In other works i want that to load the data just when the button "_btn" is clicked, but without show root node.

    1 - View
    <ext:Button ID="_btn" Text="add" runat="server">
        <Listeners>
            <Click Handler="doLoad();" />
        </Listeners>
    </ext:Button>
    <ext:TreePanel ID="TreePanel1" runat="server" Title="Tree" Height="500" Width="200"
        Border="false">
        <Store>
            <ext:TreeStore ID="TreeStore1" NodeParam="nodeId" runat="server">
                <Proxy>
                    <ext:AjaxProxy Url="/Example/loadNodeChildren">
                        <Reader>
                            <ext:JsonReader Root="data" />
                        </Reader>
                    </ext:AjaxProxy>
                </Proxy>
            </ext:TreeStore>
        </Store>
        <Root>
            <ext:Node NodeID="0" Text="Ext" />
        </Root>
    </ext:TreePanel>
    2 -Controller
    public StoreResult loadNodeChildren(string nodeId)
    {
        NodeCollection nodes = new NodeCollection(false);
    
        if (!string.IsNullOrEmpty(nodeId))
        {
            for (int i = 1; i < 6; i++)
            {
                Node asyncNode = new Node();
                asyncNode.Text = nodeId + i;
                asyncNode.NodeID = nodeId + i;
                nodes.Add(asyncNode);
            }
        }
    
        return new StoreResult { Data = nodes.ToJson() };
    }
    3 - JavaScript
    var doLoad = function () {
        //Trigger load
    }
    Last edited by Daniil; May 18, 2012 at 5:01 PM. Reason: [CLOSED]
  2. #2
    I could remove the root node from TreePanel
    <ext:Button ID="_btn" Text="add" runat="server">
        <Listeners>
            <Click Handler="doLoad();" />
        </Listeners>
    </ext:Button>
    <ext:TreePanel ID="TreePanel1" runat="server" Title="Tree" Height="500" Width="200"
        Border="false">
        <Store>
            <ext:TreeStore ID="TreeStore1" NodeParam="nodeId" runat="server">
                <Proxy>
                    <ext:AjaxProxy Url="/Example/loadNodeChildren">
                        <Reader>
                            <ext:JsonReader Root="data" />
                        </Reader>
                    </ext:AjaxProxy>
                </Proxy>
            </ext:TreeStore>
        </Store>
    </ext:TreePanel>
    And then add it when button _btn is clicked.
    var doLoad = function () {
        App.TreePanel1.setRootNode({
            expanded: true
        });
        //how to hide the root node?
    }
    but how to hide the root node?
  3. #3
    Hi,

    Please set up:
    <ext:TreeStore runat="server">
        <CustomConfig>
            <ext:ConfigItem Name="autoLoad" Value="false" Mode="Raw" />
        </CustomConfig>    
    </ext:TreeStore>
    We will review it to allow setting it via the TreeStore AutoLoad property.
  4. #4
    I did it setting TreePanel´s RootVisible property to false and overriding the Ext.tree.View.setRootNode function, as shown bellow. Then i just set the node of the store when the button _btn is clicked

    But your approach is MUCH better
    var doLoad = function () {
        App.TreePanel1.view.store.setNode(App.TreePanel1.getRootNode());
    }
    
    Ext.tree.View.override({
    
        setRootNode: function (node) {
            var me = this;
            //me.store.setNode(node);
            me.node = node;
            if (!me.rootVisible) {
                //node.expand();
            }
        }
    });
  5. #5
    Daniil, please mark as as resolved.
  6. #6
    Thanks for the update.

    I would prefer to mark the thread as closed after a decision on this aspect:
    Quote Originally Posted by Daniil View Post
    We will review it to allow setting it via the TreeStore AutoLoad property.
  7. #7
    Now you can just set up
    <ext:TreeStore runat="server" AutoLoad="false">
    instead of using CustomConfig.

    Thanks for the question.

Similar Threads

  1. [CLOSED] Delay loading of data
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Aug 08, 2012, 4:20 PM
  2. [CLOSED] When Trigger DragDrop , to check data
    By gs_user in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: May 14, 2012, 10:18 AM
  3. [CLOSED] GridPanel Loading with Large Data Set
    By bethc in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 28, 2009, 2:20 PM
  4. [CLOSED] Combobox not loading data
    By tdracz in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 22, 2009, 6:45 AM
  5. Replies: 2
    Last Post: Sep 25, 2008, 4:28 AM

Posting Permissions