My Store looks like that:
Code:
Ext.define('Master.store.NavItems', {
extend : 'Ext.data.TreeStore',
model : 'Master.model.NavItem',
autoLoad: false,
root : {
expanded: true,
id : 'root'
},
folderSort : true,
sorters : [{
property : 'leaf',
direction : 'ASC'
}, {
property : 'text',
direction : 'ASC'
}],
buffered : false,
pageSize : null,
fillNode : function (node, records) {
[...]
}
});
Any my tree:
Code:
Ext.define('Master.view.masterController.NavTree', {
extend : 'Ext.tree.Panel',
alias : ['widget.navtree'],
title : 'Navigation',
cls : 'nav',
iconCls : 'silk-package',
tools : [{
type : 'refresh'
}],
/**
* Init Component
*/
initComponent : function(){
var me = this;
Ext.apply(this, {
stateful : true,
stateId : this.id + '-state',
stateEvents : ['itemcollapse','itemexpand'],
autoScroll : true,
columns : [{
xtype : 'treecolumn',
flex : 1,
sortable : true,
dataIndex : 'text'
},{
xtype : 'templatecolumn',
align : 'right',
style : 'margin-right:2px;',
hidden : this.hideCounterColumn,
tpl : '<span class="{[(values.count_infos_unreaded > 0) ? " treecounter" : ""]}">' +
'{[(values.count_infos_unreaded > 0) ? values.count_infos_unreaded : ""]}' +
'</span>',
width : 40
}],
dockedItems: [{
xtype: 'toolbar',
items: [{
xtype : 'textfield',
fieldLabel : 'Search',
labelWidth : 40
}]
}],
verticalScroller : {
xtype : 'schpagingscroller',
activePrefetch : false
},
viewConfig : {
storeConfig : {
buffered : true,
pageSize : me.store.pageSize || 50,
// never purge any data, we prefetch all up front
purgePageCount : 0,
refreshFromTree : function () {
var eventsWereSuspended = this.eventsSuspended;
this.suspendEvents();
this.removeAll();
var root = me.store.getRootNode(),
linearNodes = [];
var cascadeBy = function (node, func) {
func(node);
if (node.isExpanded()) {
var childNodes = node.childNodes,
length = childNodes.length;
for (var k = 0; k < length; k++) {
cascadeBy(childNodes[ k ], func);
}
}
};
cascadeBy(root, function (node) {
if (node != root) {
linearNodes.push(node);
}
});
this.cacheRecords(linearNodes);
if (!eventsWereSuspended) {
this.resumeEvents();
}
}
}
}
});
// Calling superclass
this.callParent(arguments);
},
afterRender : function(){
var me = this;
// Calling superclass
this.callParent(arguments);
// for testing here
var oldRootNode;
var fillingRoot;
var normalView = me.getView();
var nodeStore = normalView.store;
var treeStore = me.store;
var isBuffered = nodeStore.buffered;
treeStore.on('root-fill-start', function () {
fillingRoot = true;
nodeStore.suspendEvents();
if (isBuffered) {
oldRootNode = nodeStore.node;
// setting the root node of NodeStore to null - so we are now should update the NodeStore manually for all CRUD operations in tree
// with `refreshFromTree` call
nodeStore.setNode();
}
});
treeStore.on('root-fill-end', function () {
fillingRoot = false;
if (isBuffered) {
nodeStore.refreshFromTree();
nodeStore.resumeEvents();
nodeStore.guaranteeRange(0, (treeStore.pageSize || 50) - 1);
normalView.refresh();
} else {
nodeStore.resumeEvents();
normalView.refresh();
}
});
if (isBuffered) {
nodeStore.on('bufferchange', function () {normalView.refresh(); });
var updateNodeStore = function () {
if (fillingRoot) return;
nodeStore.refreshFromTree();
var rangeStart = nodeStore.guaranteedStart,
rangeEnd = nodeStore.guaranteedEnd;
delete nodeStore.guaranteedStart;
delete nodeStore.guaranteedEnd;
nodeStore.guaranteeRange(rangeStart, rangeEnd);
};
treeStore.on({
append : updateNodeStore,
insert : updateNodeStore,
remove : updateNodeStore,
move : updateNodeStore,
expand : updateNodeStore,
collapse : updateNodeStore,
sort : updateNodeStore,
buffer : 1
});
}
}
it runs without any errors- but the initial load will rendered and when i reload the tree the view is empty.
I look inside the refreshFromTree function and look into the nodeStore. nodeStore.data is always empty but nodeStore.prefetchData holds the records. What i am missing to implement?
The store data has 9 nodes and one of them have more than 800 childs. I hope your overwrite solves my performance problem if i found my fault...