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

前端 未结 5 1263
慢半拍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条回答
  •  抹茶落季
    2021-02-04 19:43

    I used a reader to achieve this effect in what I feel to be an elegant fashion. Mind you this is with a flat store and may look a little different with a tree store. The concept should translate.

    Ext.define('Ext.data.reader.a8PolicyReader', {
        extend: 'Ext.data.reader.Json',
        read: function(response) {
            var staticStuff,
                responseArr;
    
            // Static stuff
            staticStuff = [{name: 'some static user', id:1}, {name: 'another user', id:2}];
            // extract response
            responseArr = Ext.decode(response.responseText);
            // shove them together
            responseArr.concat(staticStuff);
            // read
            this.readRecords(responseArr);
        }
    })
    

提交回复
热议问题