Here is how to do it ...
refreshNode.removeAll(false);
this.getMyTreeStore().load({
node : refreshNode
});
Explanation
- refreshNode is the record/node reference
- this.getMyTreeStore() is reference to your Tree Store
- refreshNode.removeAll(false) is not really needed, this is only to fix an ExtJs 4 bug
ExtJs 4 bug when reloading a node that was already loaded once
Uncaught TypeError: Cannot call method 'indexOf' of undefined. I have wasted a lot of time on this bug, If you see this error then make sure you call Node.removeAll(false) before doing a reload or use a TreeStore override for the load function as shown below
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 hasn't 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]);
}
});
No comments:
Post a Comment
NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.