6

The test case in fiddle is working with autoLoad: true but with autoLoad: false (line 86) the load() function called at line 161 in the TreePanel beforerender event does not load the data...

For (non tree) panels I allways have set autoLoad to false and load the store on render of the GridPanel and it works perfectly. I do it like this to prevent loading all the stores at the beginning (and to set filters sometimes).
The beforeload event of the store is preventing double-load.

Where is my fault for this TreeStore ? I am looking for a solution for a long time without any result...

Michel
  • 571
  • 1
  • 4
  • 19
  • I also asked the question in the [Sencha forum](https://www.sencha.com/forum/showthread.php?309963-TreeStore-different-behaviour-beetween-autoLoad-configuration-and-load()-function) – Michel Mar 31 '16 at 07:58

2 Answers2

1

There has been similar issue in Ext JS 4 explained here ExtJS 4. Hidden treepanel with autoload false .

What I did in your fiddle is that I just added the following

  autoLoad: false,
  root:{
    //expanded: true, // optional
    children: []
  }

to line 91 in your store configuration. Everything worked magically.

Michel
  • 571
  • 1
  • 4
  • 19
nenadg
  • 420
  • 11
  • 16
  • `root: {expanded: true}` is the same non-working solution than qmat... This setting sets indirectly autoLoad to true. – Michel Apr 05 '16 at 16:26
  • @Michel actually it's `children: []` property that counts, `expanded` could also be false. – nenadg Apr 05 '16 at 16:50
  • @Michel here is working fiddle https://fiddle.sencha.com/#fiddle/1873 (I've put a defer to store.load in `beforerender`) – nenadg Apr 05 '16 at 17:25
0

I think I've solved your problem.

Use the root property for your TreeStore.

/*
 * Store
 */
Ext.define('Chronos.store.Clockings', {
    extend  : 'Ext.data.TreeStore',
    requires: [
        //'Chronos.store.Session'
    ],
    model       : 'Chronos.model.Presence',
    autoLoad    : false, //true, // false,
    //autoSync    : true, // DEBUG
    sortOnLoad  : false,
    pageSize    : 0,
    remoteFilter: true,

    root: {
       id: 'id',
       expanded: true
    },

    listeners: {
        load: function(treestore, records, success) {
            console.log(Date(), 'clockings loaded: ', success, treestore);
        },
        beforeload: function (treestore) {            
            if(treestore.isLoading()) return false;        
        }
    }
});

Hope this is what you are looking for!

qmateub
  • 512
  • 4
  • 9
  • Unfortunatly not because `It's important to note that Tree Stores will load regardless of autoLoad's value if expand is set to true on the root node.` according to [the documentation](http://docs.sencha.com/extjs/5.1/5.1.1-apidocs/#!/api/Ext.data.TreeStore-cfg-autoLoad). That means that your code sets autoLoad to true indirectly and that is not what I am looking for. – Michel Mar 19 '16 at 19:04