[CLOSED] Tree panel should refresh and the selected node should remain.

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Tree panel should refresh and the selected node should remain.

    Hi

    I have a tree panel and a form panel, on selction of any node in the tree, the corresponding node name is displayed in the form panel.
    I can also edit the name in the form panel. and on click of the save button, the selected node should change the name in the tree panel and the selection should remain.

    i have used treepanel.RefreshTree();
    but the selection goes off..

    Thank you
    Last edited by geoffrey.mcgill; Sep 08, 2011 at 6:01 PM. Reason: CLOSED
  2. #2
    You can save selected node id and restore selection after reloading, just ensure that all nodes have id

    Get selected node id
    TreePanel1.getSelectionModel().getSelectedNode().id
    Select a node after tree reloading
    TreePanel1.getNodeById(savedId).select();
  3. #3
    Hi, this is my code

    var CompanyID = parent.TreePanel1.getSelectionModel().getSelectedNode().id;
    parent.RefreshTree();
    parent.TreePanel1.getNodeById(CompanyID).select();
    when i do this, it cant find CompanyID

    if i remove
    parent.RefreshTree();
    then the tree does not get the edited name.
  4. #4
    i guess that your RefreshTree is async operation (for example, direct method) therefore you have to restore node selection in the success callback of direct method
  5. #5
    hi,

    In
    parent.RefreshTree();
    i just do
    TreePanel1.getRootNode().reload();
    where only child node of the async root node is shown.
    so how do i use callback function. or
    help me to show all the nodes of the async root node.
  6. #6
    'reload' method accepts callback as first argument
    tree.getRootNode().reload(function(){
           // restore node selection here
    });
    help me to show all the nodes of the async root node.
    Just return all nodes instead direct children only
  7. #7
    If you have trubles then it is better to post simple test sample and we will change it as required
  8. #8
    Just return all nodes instead direct children only
    is there any function of property for this

    Because i am doing this
    TreePanel1.getRootNode().reload(function () {
                    TreePanel1.getNodeById(CompanyID).select(); 
                });
    and throw the error Ext.fly error.


    Below is my tree panel
    <ext:TreePanel Height="600" Layout="Fit" ID="TreePanel1" Lines="true" runat="server" Draggable="false"
        Frame="false" UseArrows="false" AutoScroll="true" Animate="true" EnableDD="false" CollapseFirst="false" 
        ContainerScroll="true" Border="false" RootVisible="false" AutoDataBind="true" IDMode="Explicit" 
        AutoDestroy="true">
        <Loader>    
            <ext:TreeLoader DataUrl="/Common/GetCompanyTree" PreloadChildren="true">
                <BaseAttributes>
                    <ext:Parameter Name="nodeType" Value="node" Mode="Value" />
                </BaseAttributes>
                <BaseParams>
                    <ext:Parameter Name="Feature" Value="#{SelectedType}.text" Mode="Raw">
                    </ext:Parameter>
                </BaseParams>
            </ext:TreeLoader>        
        </Loader>  
        <Listeners> 
            <ContextMenu Handler="#{CompanyMenu}.node = node;node.select();#{CompanyMenu}.showAt(e.getXY());" />
            <AfterRender Handler="RegEvent();" />    
        </Listeners>
        <Root>
            <ext:AsyncTreeNode NodeID='0' Draggable="false" Icon="BuildingKey" Expanded="false" >
            </ext:AsyncTreeNode>
        </Root>
        <DirectEvents>
            <Click Url="/Common/TreeNodeSelection" Before="LoadPage();">
                <ExtraParams>
                    <ext:Parameter Name="id" Value="node.id" Mode="Raw" />
                    <ext:Parameter Name="text" Value="#{TreePanel1}.getSelectionModel().getSelectedNode().text" Mode="Raw" />
                    <ext:Parameter Name="NodeType" Value="#{SelectedType}.text" Mode="Raw" />
                </ExtraParams>
            </Click>
            
        </DirectEvents>
    </ext:TreePanel>
  9. #9
    Can you provide test sample which can be run localy?

    NOTE: No further information provided. Marking thread as [CLOSED].
    Last edited by geoffrey.mcgill; Sep 08, 2011 at 6:01 PM.
  10. #10
    How to select saved item from treepanel after page reload ?... in codebehinde
    TreePanel1.getNodeById(CompanyID).select();
    is absent
    Last edited by ginsar; Oct 07, 2011 at 6:20 AM.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: Oct 26, 2012, 8:52 AM
  2. Replies: 3
    Last Post: Jul 03, 2012, 12:31 AM
  3. [CLOSED] TreePanel refresh tree node
    By boris in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 16, 2011, 10:32 AM
  4. [CLOSED] How to get the current node selected in a tree panel?
    By flormariafr in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Aug 13, 2010, 4:43 PM
  5. Selected Node - tree panel
    By filipator in forum 1.x Help
    Replies: 3
    Last Post: Mar 25, 2009, 2:58 PM

Posting Permissions