我的treelist
定义如下:
{
xtype: "treelist",
itemId: "MainMenu",
store: {
root: {
expanded: true,
children: [{
text: "One",
leaf: true,
iconCls: "x-fa fa-frown-o"
}]
}
}
}
当我加载页面时,我看到此treelist已呈现正常。然后我点击一个按钮,执行以下代码:
mainmenu.getStore().add({
text: "Two",
leaf: true,
iconCls: "x-fa fa-frown-o"
});
console.log(mainmenu.getStore().getCount()); // prints out correct value 2
问题是我仍然只看到treelist
中的一个项目。换句话说,treelist
商店中填充了新数据,但未显示。那么,我该如何解决呢?我想应该有某种刷新或更新方法,这将刷新树视图。
答案 0 :(得分:1)
您的问题可能是错误地使用了TreeStore。树存储有一个根,并且TreeList的子节点递归地显示在TreeList中。但是,要实际添加到树存储中,您应该使用NodeInterface。
在你的情况下:
mainmenu.getStore().getRootNode().appendChild({
text: "Two",
leaf: true,
iconCls: "x-fa fa-frown-o"
});