gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 15:36:05 24 4
gpt4 key购买 nike

我正在使用带有底层 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com