sencha-touch-2 - Sencha 触摸 2 : Insert into TreeStore/NestedList

标签 sencha-touch-2 nested-lists tree-structure

我正在使用带有底层 TreeStore 的 NestedList。现在我想将项目作为叶子添加到 NestedList 中。
我怎样才能做到这一点?

目前我的代码( Controller ,onAddButtonTapped)如下所示:

var store = Ext.getStore('menuStore');
var customerAreaNode = store.getRoot().getChildAt(1);  
customerAreaNode.appendChild({name: "text", leaf:true});
customerAreaNode.expand();
store.sync();

此代码在叶级别(在正确的节点后面)产生两个新的空监听,并在节点级别产生一个新的监听。
每个新条目在 NestedList 中都没有显示名称,但每个项目的名称字段中都包含“文本”。奇怪的是,叶级别的新条目之一没有输入到基础模型中。所以找不到对应模型的方法:
Uncaught TypeError: Cannot call method 'getSelectedName' of undefined

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

最佳答案

叶项的默认显示字段是“文本”。 You can get the information from here.如果要使用“文本”作为显示字段,则需要将此行更改为

customerAreaNode.appendChild({text: "text", leaf:true});

或者您可以更改嵌套列表的显示字段,因此您的模型此时不需要更改。
yournestedlist.setDisplayField('name');

希望这可以帮助。

关于sencha-touch-2 - Sencha 触摸 2 : Insert into TreeStore/NestedList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9767890/

相关文章:

javascript - ExtJS 和 Sencha Touch : Adding a second panel at bottom with text that depends on a function call

sencha-touch-2 - 在 Sencha CMD 中构建失败

javascript - Sencha Touch 2 应用程序与 Cordova 3.1 在 iOS 7 上运行缓慢

python - 在深度嵌套和不可预测的列表中将 python 十进制转换为字符串

javascript - 返回带有过滤子数组的父对象

filesystems - 持久性:数据树存储为目录树

c# - 有 parent 和 child 的树结构

html - 列表项 Tpl 问题 : List that has not been rendered with two arrays as two columns

c# - 我需要像树结构一样在下拉列表中显示数据,我尝试过但无法在 ASP.Net 中正确显示

python - 元组列表的唯一排列