PDA

View Full Version : Ext.data.TreeStore#setRootNode doesn't accept Model instance



PHaroZ
13 Oct 2011, 6:59 AM
In Ext 4.0.6

According to API doc setRootNode (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.data.TreeStore-method-setRootNode) should accept an Ext.data.Model instance, but it seem to be bogus. My instance is always wrapped again in a new Model instance.

My override :

Ext.override(Ext.data.TreeStore, {
setRootNode : function(root) {
var me = this;

root = root || {};
if (!root.isModel) { // instead of root.isNode
Ext.applyIf(root, {
id : me.defaultRootId,
text : 'Root',
allowDrag : false
});
root = Ext.ModelManager.create(root, me.model);
}
Ext.data.NodeInterface.decorate(root);

me.getProxy().getReader().buildExtractors(true);

me.tree.setRootNode(root);

if (!root.isLoaded() && (me.autoLoad === true || root.isExpanded())) {
me.load({
node : root
});
}

return root;
}
});
I think this is that ext team wanted to write.