2012-02-16 2 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에 새 데이터로 새 UI를 새로 고치고 표시하려면 어떻게합니까?

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