2012-02-16 80 views
0

因此,让我们在煎茶触摸说,我创建了一个嵌套列表,像这样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: 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刷新并显示新的用户界面?

b)我的实施createList()是最适合创建Nestlisted的方法吗?还是有更好的方式来达到我的目的?

回答

0

因为没有人及时回答我的问题,所以我用了一个工作。

我在问题中保留了代码。嵌套列表由容器面板使用。所以我做的是从容器面板中删除旧的嵌套列表,将其销毁,然后创建一个新的嵌套列表,并将其插回容器面板。举个例子:

// 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 
相关问题