Sencha touch Sencha Touch-如何在嵌套列表中显示最新内容?
比如说在Sencha Touch中,我创建了一个嵌套列表,如下所示Sencha touch Sencha Touch-如何在嵌套列表中显示最新内容?,sencha-touch,refresh,nested-lists,Sencha Touch,Refresh,Nested Lists,比如说在Sencha Touch中,我创建了一个嵌套列表,如下所示 var NestedList = createList(jsonDataObject,'leftNavigation','list','bookmark-icon'); function createList( data , id , cls, iconCls) { var store = new Ext.data.TreeStore({ model: 'ListItem', root:
var NestedList = createList(jsonDataObject,'leftNavigation','list','bookmark-icon');
function createList( data , id , cls, iconCls)
{
var store = new Ext.data.TreeStore({
model: 'ListItem',
root: data,
proxy: {
type: 'ajax',
reader: {
type: 'tree',
root: 'items'
}
}
});
var leftNav = new Ext.NestedList({
// cardSwitchAnimation: false,
dock: 'left',
id: id,
cls: 'card '+cls,
useTitleAsBackText: true,
title: data.text ,
iconCls: iconCls,
displayField: 'text',
width: '350',
store: store});
}
一段时间后,jsonDataObject
的内容将发生更改(通过setInterval()
调用定期更改,或者由于用户交互)。我可能还需要向NestedList
存储提交一个全新的jsonDataObject
。因此,我的问题是:
a) 如何让NestedList
刷新并显示包含新数据的新UI
b) 我的
createList()
实现是否是创建嵌套列表的最合适方法?还是有更好的方法来达到我的目的 因为没有人及时回答我的问题,所以我采用了变通办法
我保留了问题中的代码。嵌套列表由容器面板使用。所以我所做的就是从容器面板中删除旧的nestedlist,销毁它,然后创建一个新的nestedlist,并将其插入到容器面板中。例如:
// my old nestedlist was item 1 of the container, where container is Ext.TabPanel()
// you can re-use this strategy with any component in the container.items.items array
var oldnestedlist = container.items.items[1];
container.remove(oldnestedlist);
oldnestedlist.destroy();
// create the new nestedlist
var NestedList = createList(jsonDataObject,'leftNavigation','list','bookmark-icon');
container.insert(1,NestedList);
// After you insert the NestedList, the screen hasn't been redrawn yet,
// so i force the user to go back to screen if container.items.items[0] via
// setActiveItem(0). You can choose the screen in any other
// container.items.items array
container.setActiveItem(0);
// Next time someone presses the tab for containers.items.items[1], the screen will automatically redraw