-
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
-
28 Feb 2012 6:46 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 434
I would think you should at least have the text field specified but we will get this fixed.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
1 Mar 2012 5:24 AM #3
I noticed this behaviour only yesterday (NodeInterface gets applied to prototype of my model). My question is how to get my original model fields back? I also use my model in other parts of my app, e.g. in a PropertyGrid which is now populated by unwanted fields!
-
2 Mar 2012 9:49 AM #4
It took me a while to figure out but the workaround I used was to specify the following in the fields array property (seen above):
Does this help you DiscoBoy?Code:{ name: 'text', type: 'string' }
-
5 Mar 2012 5:38 AM #5
Thx for your suggestion. I currently just remove all "persitent=false" fields from my object copy that is configured as source in my PropertyGrid. This avoidsappearing the NodeInterface attributes in my grid.
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