Results 1 to 8 of 8

Thread: selecting first node of tree-list under architect

  1. #1
    Sencha User
    Join Date
    Feb 2017
    Posts
    17
    Answers
    1

    Default Answered: selecting first node of tree-list under architect

    I have adapted the Admin-Dashboard example to work under Sencha Architect with some success,
    by reverse engineering the containers etc.

    It uses and Ext.list.Tree as the menu.
    Even the example Admin-Dashboard example project (extJS 6) from sencha
    does not do what I want to do: pre-select the first menu item to highlight it.

    I can render the menu and listen to the selectionchange event of the treelist and make the menu
    change views in a container with cards. All is fine. I just want to pre-select the first menu item.

    It's a minor thing but once the user starts clicking, the menu items (tree nodes) are highlighted and
    selected nicely. But I want to have an initial selection.

    I am trying the code seen here:
    https://fiddle.sencha.com/#fiddle/1fpq&view/editor
    but that was for a button handler:

    handler: function() {
    var treelist = panel.down('treelist'),
    store = treelist.getStore(),
    record = store.getAt(1);
    treelist.setSelection(record); }


    I cannot figure out what object (container or tree-view) and what event or event listener or p
    roperty I could use to pre-select the first node of my tree without clicking on it.

    Can you suggest an event? on the tree? the container its in?

    Thanks. Carl

  2. Ok, I got it working by using SHOW and only on the outermost container of a hierarchy of them.
    The show events (and afterrender) events don't work in nested containers.
    onContainerShow: function(component, eOpts) {
    alert('show');
    var treelist = component.down('treelist'),
    store = treelist.getStore(),
    record = store.getAt(1);

    treelist.setSelection(record);
    }

    Does Architect disable features and events that should work according to ExtJS 6 documentation?
    Sure, I expect older ExtJS 5 and earlier things not to work, but this makes even more of the online documentation
    misleading - including even the wonderful advice you gave me about afterrender.


    Thanks.
    Carl

    addendum. this is the best answer. We later realized why afterrender does not exist. I am using the modern toolkit.


  3. #2
    Sencha User
    Join Date
    Sep 2014
    Location
    Central Europe
    Posts
    795
    Answers
    103

    Default

    Hi Carl

    I think that you can use event afterrender on the panel http://docs.sencha.com/extjs/6.2.0/c...nt-afterrender

    Fiddle https://fiddle.sencha.com/#fiddle/1rod&view/editor

    Regards
    Petr

  4. #3
    Sencha User
    Join Date
    Feb 2017
    Posts
    17
    Answers
    1

    Default

    Does it have to be a Panel? I had it in a simple Container - as per the Admin-Dashboard example.
    I thought I tried afterrender on the container but maybe I had it on the tree. Will try it and get back to you, many thanks.
    Carl

  5. #4
    Sencha User
    Join Date
    Sep 2014
    Location
    Central Europe
    Posts
    795
    Answers
    103

    Default

    Quote Originally Posted by Carl.Wagar View Post
    Does it have to be a Panel?
    Container is also fine, I have updated the fiddle with container instead of panel https://fiddle.sencha.com/#fiddle/1rod&view/editor

    Quote Originally Posted by Carl.Wagar View Post
    I thought I tried afterrender on the container but maybe I had it on the tree. Will try it and get back to you, many thanks.
    Yeah it seems that tree-list itself doesn't have any nice event we could use.

  6. #5
    Sencha User
    Join Date
    Feb 2017
    Posts
    17
    Answers
    1

    Default

    Ok, it turns out that doesn't work under ExtJS 6.2.1 and Architect 4.
    All documentation indicates a Container should have an afterrender, but it doesn't.

    Interestingly, in Sencha Architect, when you click on the Event Bindings for ANY container it does NOT
    show afterrender. Is there something about the architect environment that prevents this?
    I can manually type afterrender and it does put in the listener in the view controller, and even
    if I just do an alert, it doesn't call the method.


  7. #6
    Sencha User
    Join Date
    Feb 2017
    Posts
    17
    Answers
    1

    Default

    Ok, I got it working by using SHOW and only on the outermost container of a hierarchy of them.
    The show events (and afterrender) events don't work in nested containers.
    onContainerShow: function(component, eOpts) {
    alert('show');
    var treelist = component.down('treelist'),
    store = treelist.getStore(),
    record = store.getAt(1);

    treelist.setSelection(record);
    }

    Does Architect disable features and events that should work according to ExtJS 6 documentation?
    Sure, I expect older ExtJS 5 and earlier things not to work, but this makes even more of the online documentation
    misleading - including even the wonderful advice you gave me about afterrender.


    Thanks.
    Carl

    addendum. this is the best answer. We later realized why afterrender does not exist. I am using the modern toolkit.


  8. #7
    Sencha User
    Join Date
    Sep 2014
    Location
    Central Europe
    Posts
    795
    Answers
    103

    Default

    Hi Carl

    The Architect should follow the docs, also anything which can be done in plain ExtJS should be possible to do in Architect.

    Anyway are you on ExtJS 6.2.1 Classic or Modern? The modern doesn't have event afterrender
    http://docs.sencha.com/extjs/6.2.1/m...Container.html

    This event is only in Classic and I am seeing event afterrender in the classic projects in SA. And if the show event is working for you, it should be good solution too.

    Regards
    Petr

  9. #8
    Sencha User
    Join Date
    Feb 2017
    Posts
    17
    Answers
    1

    Default

    AHA. Ok, that explains it. Yes, I am using modern. Ok great.
    I am very glad to hear that Architect should generate standard code but that we have
    to watch - that much of the documentation is for 'classic' and may not work.
    Yes, I SHOW works and now I know!
    Thanks very much for the assistance!
    Carl

Similar Threads

  1. Selecting Last node of the tree after tree loaded
    By sanjayon19 in forum Ext: Discussion
    Replies: 3
    Last Post: 22 Jan 2014, 1:25 PM
  2. Replies: 2
    Last Post: 11 Apr 2012, 2:45 AM
  3. selecting the Tree node
    By mango in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 11 Nov 2009, 2:15 PM
  4. 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

Posting Permissions

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