Threaded View
-
27 Feb 2012 9:19 AM #1
[4.1 b3] TreeStore doesn't copy all standard Tree field's.
[4.1 b3] TreeStore doesn't copy all standard Tree field's.
I've found a bug when using a TreePanel with additional fields where the standard Tree field "text" isn't copied over into the Model.
* According to the Ext.data.TreeStore documentation:Code:new Ext.tree.TreePanel({ flex: 1, style: 'padding-left: 5px;', useArrows: true, //border: false, rootVisible: false, autoScroll: true, root: { // NodeInterface text: "All", expanded: true }, fields: [{ name: 'myCustomField', type: 'string' }] });
Using Models
If no Model is specified, an implicit model will be created that implements Ext.data.NodeInterface. The standard Tree fields will also be copied onto the Model for maintaining their state. These fields are listed in the Ext.data.NodeInterface documentation.
* According to the Ext.data.NodeInterface documentation:
This class is used as a set of methods that are applied to the prototype of a Model to decorate it with a Node API. This means that models used in conjunction with a tree will have all of the tree related methods available on the model. In general this class will not be used directly by the developer. This class also creates extra fields on the model if they do not exist, to help maintain the tree state and UI. These fields are documented as config options.
* The text field is documented as a config option:
Config options
...
text : String
The text for to show on node label.
The text field however is clearly missing when I try to do anything with the node. After inspecting the source the "text" field is missing from the NodeInterface source code:
I've followed the documentation so either there is a bug in the source of ExtJS 4.1 Beta 3 or there is a mistake in the in the documentation.Code:decorate: function(modelClass) { var idName, idType; if (typeof modelClass == 'string') { modelClass = Ext.ModelManager.getModel(modelClass); } if (modelClass.prototype.isNode) { return; } idName = modelClass.prototype.idProperty; idType = modelClass.prototype.fields.get(idName).type.type; modelClass.override(this.getPrototypeBody()); this.applyFields(modelClass, [ {name: 'parentId', type: idType, defaultValue: null}, {name: 'index', type: 'int', defaultValue: null, persist: false}, {name: 'depth', type: 'int', defaultValue: 0, persist: false}, {name: 'expanded', type: 'bool', defaultValue: false, persist: false}, {name: 'expandable', type: 'bool', defaultValue: true, persist: false}, {name: 'checked', type: 'auto', defaultValue: null, persist: false}, {name: 'leaf', type: 'bool', defaultValue: false}, {name: 'cls', type: 'string', defaultValue: null, persist: false}, {name: 'iconCls', type: 'string', defaultValue: null, persist: false}, {name: 'icon', type: 'string', defaultValue: null, persist: false}, {name: 'root', type: 'boolean', defaultValue: false, persist: false}, {name: 'isLast', type: 'boolean', defaultValue: false, persist: false}, {name: 'isFirst', type: 'boolean', defaultValue: false, persist: false}, {name: 'allowDrop', type: 'boolean', defaultValue: true, persist: false}, {name: 'allowDrag', type: 'boolean', defaultValue: true, persist: false}, {name: 'loaded', type: 'boolean', defaultValue: false, persist: false}, {name: 'loading', type: 'boolean', defaultValue: false, persist: false}, {name: 'href', type: 'string', defaultValue: null, persist: false}, {name: 'hrefTarget', type: 'string', defaultValue: null, persist: false}, {name: 'qtip', type: 'string', defaultValue: null, persist: false}, {name: 'qtitle', type: 'string', defaultValue: null, persist: false}, {name: 'children', type: 'auto', defaultValue: null, persist: false} ]); },
If I follow the documentation then the solution is to "hack" the "text" field into the fields array. Is this a bug?Last edited by karlsnyder0; 27 Feb 2012 at 9:20 AM. Reason: comments between documentation pasting stand out
You found a bug! We've classified it as
EXTJSIV-5480
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.



Reply With Quote