MatiasGSP
MatiasGSP

Reputation: 95

ExtJS - showing preloaded value of treepanel's store

I'm using ExtJS 6.2. I have a xtype: 'treepanel' that allows an admin user type to check several companies. If user_type = company, then the treepanel is preloaded with that company's node checked value as true, and also I set 'beforecheckchange' listener to return false, so that user cannot select any other company.

What I would like to achieve now is to focus the store on to that preloaded value. In other words, I don't want the user to scroll to find its company's node checked, I would like to preset that position to show the checked node right away.

Any orientation on how to achieve this would be appretiated.

Upvotes: 0

Views: 40

Answers (1)

MatiasGSP
MatiasGSP

Reputation: 95

Achieved using treepanel's selectPath method, in afterlayout event:

afterlayout: function(me){
                  var type = localStorage.getItem("Usertype");
                  var id = localStorage.getItem("Id");
                  var tree = Ext.getCmp('your_treepanel_id')
                  if(type==desiredUserFilter) {
                        var child = me.getRootNode().findChild('id',id,true)
                        tree.selectPath(child)
                  }
              },

Upvotes: 0

Related Questions