Selecting root node in TreePanel loaded with Ajax

  1. #1

    Selecting root node in TreePanel loaded with Ajax

    hi,

    i am using TreePanel with TreeStore and AjaxProxy like that:

    <ext:TreePanel
                            
                            ID="StoresTreePanel"
                            Border="false"
                            RootVisible="false"
                            runat="server">
                            <Root>
                                <ext:Node NodeID="0" />
                            </Root>
                            <Store>
                                <ext:TreeStore runat="server">
                                    <Proxy>
                                        <ext:AjaxProxy Url="TreeStoresLoader.ashx" />
                                    </Proxy>
                                </ext:TreeStore>
                            </Store>
                            <DirectEvents>
                                <ItemClick OnEvent="GetPriceLists">
                                    <ExtraParams>
                                        <ext:Parameter Name="Id" Value="record.id" Mode="Raw" />
                                    </ExtraParams>
                                </ItemClick>
                            </DirectEvents>
                            <SelectionModel>
                                <ext:RowSelectionModel ID="TreePanelSelectionModel" runat="server" />
                            </SelectionModel>
                        </ext:TreePanel>
    my ashx file create NodeCollection and then:
     context.Response.Write(nodes.ToJson());
     context.Response.End();

    Also upon selecting node in the tree i set direct event to be called (ItemClick).

    what i am trying now is to select the root Primary node in the first NodeCollection that is render
    so that when the tree is show up the root will be selected automaticlly (including triggering the ItemClick event)

    i hope that you understand my goal here.
    i couldnt find any example that demonstarte this.
  2. #2
    Hello @eitanby!

    Assuming you have a tree panel, previously loaded, under ID TreePanel1, you could select its root node by calling, client-side:

    App.TreePanel1.getSelectionModel().select(App.TreePanel1.getRootNode());
    Now, I'm not sure you're going to get an itemClick event triggered here, as the tree panel's selection model does not have this event, but the select one. Notwithstanding, I believe the select one would be more appropriate to be triggered on select, right? Unless you need the event to be triggered every time the tree node is clicked, regardless of being the selected entry or not (as if it was a link, maybe).

    I hope this helps!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. TreePanel without Root node
    By Dominik in forum 1.x Help
    Replies: 3
    Last Post: Jun 25, 2014, 7:07 PM
  2. TreePanel node loaded: true to have node cached.
    By millenovanta in forum 2.x Help
    Replies: 0
    Last Post: Nov 28, 2013, 11:32 AM
  3. Replies: 1
    Last Post: Oct 16, 2013, 7:21 PM
  4. Replies: 0
    Last Post: Aug 09, 2012, 8:30 AM
  5. Replies: 0
    Last Post: May 27, 2009, 6:30 PM

Tags for this Thread

Posting Permissions