Sencha touch 2 Sencha Touch 2:插入到TreeStore/NestedList中

Sencha touch 2 Sencha Touch 2:插入到TreeStore/NestedList中,sencha-touch-2,nested-lists,tree-structure,Sencha Touch 2,Nested Lists,Tree Structure,我正在使用一个嵌套列表和一个底层树存储。现在我想将项目作为叶子添加到NestedList中。 我该怎么做 目前我的代码(控制器,onAddButtonTapped)如下所示: var store = Ext.getStore('menuStore'); var customerAreaNode = store.getRoot().getChildAt(1); customerAreaNode.appendChild({name: "text", leaf:true}); customerAr

我正在使用一个嵌套列表和一个底层树存储。现在我想将项目作为叶子添加到NestedList中。 我该怎么做

目前我的代码(控制器,onAddButtonTapped)如下所示:

var store = Ext.getStore('menuStore');
var customerAreaNode = store.getRoot().getChildAt(1);  
customerAreaNode.appendChild({name: "text", leaf:true});
customerAreaNode.expand();
store.sync();
这段代码在叶级(正确节点后面)生成两个新的空listentry,在节点级生成一个新的listentry。 NestedList中没有显示每个新条目的名称,但每个条目的名称字段中都包含“文本”。奇怪的是,叶级的一个新条目没有被输入到底层模型中。因此,无法找到模型对应的方法:

Uncaught TypeError: Cannot call method 'getSelectedName' of undefined

有人知道如何将数据添加到NestedList/TreeStore的简单教程吗?我在sencha touch文档中找不到一个好的例子

叶项目的默认显示字段为“文本”。如果要使用“文本”作为显示字段,则需要将此行更改为

customerAreaNode.appendChild({text: "text", leaf:true});
或者,您可以更改嵌套列表的显示字段,以便您的模型此时不需要更改

yournestedlist.setDisplayField('name');

希望这能有所帮助。

在我的例子中,我用以下方式更新根节点和子节点

Ext.getStore('Contactsstore').getAt(1).getChildAt(0).set('Email',contactemail);    
Ext.getStore('Contactsstore').getAt(1).set('ContactTitle',contacttitle);
这可能会有帮助:---我在手机上,所以我不能测试代码,看看这是否能让你开始