Results 1 to 4 of 4

Thread: Selecting first node In a Tree panel after rendering

  1. #1
    Sencha User vick_44's Avatar
    Join Date
    Jul 2016
    Posts
    64
    Answers
    6

    Default Answered: Selecting first node In a Tree panel after rendering

    Possibly duplicate of

    https://www.sencha.com/forum/showthr...e-after-Render

    But i dint wanted to reopen an old thread and i am using extjs 4.1.1.


    I have a treepanel where none of the leafs are selected by default, i want the first leaf need to be selected by default. I found few solutions on the internet where it shows how to do that, but it doesnt seem to work for me. Below is the code that i am using. This is part of a bigger application. When i place a debugger in afterrender listener, and execute the lines one by one the code works but If i remove the debugger then it doesnt. I am suspecting it may be due to timing, that is, when i place debugger, i am giving sufficient time for the application to load completely.


    Is there any possible way around my problem?.
    any help is deeply appreciated.


    references:


    https://www.sencha.com/forum/showthr...e-after-Render
    http://jsfiddle.net/TBa2E/




    my code:


    Code:
    Ext.define('XXXXXXX.store.shared.MenuTreeStore', {
        extend: 'Ext.data.TreeStore',
        requires: 'XXXXXXX.model.shared.MenuTreeModel',
        model: 'XXXXXXX.model.shared.MenuTreeModel',
        autoLoad: true,
        autoSync: true,
        clearOnLoad: true,
        clearRemovedOnLoad: true
    });
    
    
    
    
    
    
    Ext.define('XXXXXXX.model.shared.MenuTreeModel', {
        extend: 'Ext.data.Model',
        fields: [
                 { name: 'text', type: 'string'}
             ],
            proxy:{
                type: 'ajax',
                url: 'data/menuTree.json',
                reader:{
                    type:'json'
                }
            }  
    });
    
    
    
    
    Ext.define('XXXXXXX.view.shared.MenuTreePanel', {
        extend: 'Ext.tree.Panel',
        alias : 'widget.XXXXXXX.view.shared.MenuTreePanel',
        store: 'XXXXXXX.store.shared.MenuTreeStore',
        id: 'XXXXXXX-view-shared-MenuTreePanel-Id',
        useArrows: true,
        rootVisible: false,
        cls: 'no-leaf-icons',
        height: 340,
        minHeight: 340,
        padding: 0,
        bodyPadding: 0,
        border: false,
        renderTo: Ext.getBody(),
        
        listeners: {
            afterrender:function(){
                debugger;
                var record = this.getStore().getNodeById('search');
                    this.getSelectionModel().select(record);
            }
        }
    });

  2. I wasn't able to run your test case, but I put your code into this Fiddle, and it seems to run as expected.
    https://fiddle.sencha.com/#fiddle/1k31

  3. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    I wasn't able to run your test case, but I put your code into this Fiddle, and it seems to run as expected.
    https://fiddle.sencha.com/#fiddle/1k31

  4. #3
    Sencha User vick_44's Avatar
    Join Date
    Jul 2016
    Posts
    64
    Answers
    6

    Default

    Yes it working now, not sure why my application wasnt behaving as its supposed to but now its resolved. Dont see above behaviour. Thanks Gary.

  5. #4
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    Great, glad to hear it's working for you now.

Similar Threads

  1. Replies: 2
    Last Post: 11 Apr 2012, 2:45 AM
  2. selecting the Tree node
    By mango in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 11 Nov 2009, 2:15 PM
  3. Selecting node in a tree
    By dana.lees in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 17 Aug 2009, 3:41 AM
  4. Icon next to menutree node
    By mayanknext in forum Ext 2.x: Help & Discussion
    Replies: 8
    Last Post: 11 Feb 2009, 7:57 PM

Tags for this Thread

Posting Permissions

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