ExtJS 4: TreeStore with both static and dynamically-loaded data?

前端 未结 5 1264
慢半拍i
慢半拍i 2021-02-04 19:18

I\'m making a TreePanel that looks like this:

\"enter

At the moment I have it \"mo

5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-04 19:42

    I have a very similar problem, and while I haven't gotten it to work completely like I want it to, it mostly works. I have autoLoad: false and added this event handler:

    beforerender: function(comp, opts) {
        var node = this.getRootNode();
        node.appendChild({test: 'Recent', id: 'recent', expandable: true, expanded: false});
        node.appendChild({text: 'Current', id: 'current', expandable: true, expanded: false});
        node.appendChild({text: 'All', id: 'all', expandable: true, expanded: false});
    }
    

    The 3 immediate children of the root are static, then the proxy makes a request to populate them when I expand them (passing the appropriate id).

    I also had to suppress the root node from loading with a listener on the store:

            listeners: {
                beforeload: function(store, operation, opts) {
                    if (operation.node.data.id == 'root') {
                        return false;
                    }
                }               
            },
    

    Hope this helps. It seems like there should be a better way!?!

提交回复
热议问题