I'm using a NestedList with a underlying TreeStore. Now I want to add items to the NestedList as leafs. How can I do this?
Currently my code (Controller, onAddButtonTapped) looks like this:
var store = Ext.getStore('menuStore');
var customerAreaNode = store.getRoot().getChildAt(1);
customerAreaNode.appendChild({name: "text", leaf:true});
customerAreaNode.expand();
store.sync();
This code results in two new empty listentries on leaf level (behind the correct node) and one new listentry on node level. Every new entry has no names shown in the NestedList but every item contains "text" in their name field. Curiously one of the new entries at leaf level is not typed to the underlying Model. So the model-corresponding methods could't be found:
Uncaught TypeError: Cannot call method 'getSelectedName' of undefined
Does anybody know a easy tutorial how to add data into NestedList/TreeStore? I could not find one good example in the sencha touch docs.
In my case i used to update root and child nodes like the following way
The default display field for leaf items is "text". You can get the information from here. If you want to use "text" as display field, then you need to change this line to
Or you can change your nested list's display field, so your model do not need to change for this time.
Hope this helps.