Extjs4 重寫Ext.data.TreeStore的load方法,不使多次載入
阿新 • • 發佈:2019-01-05
Ext.override(Ext.data.TreeStore, {
load : function(options) {
options = options || {};
options.params = options.params || {};
var me = this, node = options.node || me.tree.getRootNode(), root;
// If there is not a node it means the user hasnt defined a rootnode
// yet. In this case lets just
// create one for them.
if (!node) {
node = me.setRootNode( {
expanded : true
});
}
if (me.clearOnLoad) {
node.removeAll(false);
}
Ext.applyIf(options, {
node : node
});
options.params[me.nodeParam] = node ? node.getId() : 'root';
if (node) {
node.set('loading', true);
}
return me.callParent( [ options ]);
}
});
load : function(options) {
options = options || {};
options.params = options.params || {};
var me = this, node = options.node || me.tree.getRootNode(), root;
// If there is not a node it means the user hasnt defined a rootnode
// yet. In this case lets just
// create one for them.
if (!node) {
node = me.setRootNode( {
expanded : true
});
}
if (me.clearOnLoad) {
node.removeAll(false);
}
Ext.applyIf(options, {
node : node
});
options.params[me.nodeParam] = node ? node.getId() : 'root';
if (node) {
node.set('loading', true);
}
return me.callParent( [ options ]);
}
});