extjs6treelist

How to make an item active(selected) by default while using Treelist(Ext.list.Tree) in Extjs 6?


I want to make the first item from a tree list be selected by default. I am working on extjs 6. Any help will be greatly appreciated.


Solution

  • Try this:

    listeners: {
        element: 'element',
        painted: function (treelistEl) {
            var treelist = treelistEl.component;
            treelist.setSelection(treelist.getStore().getRoot().firstChild);
        }
    }