2012-01-31 2 views
0

내 메뉴를 구축하기위한 프록시없이 간단한 TreeStore를 사용하고 있습니다.ExtJS4 : Treestore에서 Controller로 전달하는 매개 변수/속성

컨트롤러 :

init: function() { 

     this.control({ 

      /** 
      * Catch the treepanels in the menu accordion 
      */ 
      'menu-main treepanel': { 

       itemclick: function (view, record, item, index, event){ 

        var clickedMnuNode = record; 
        var tabPanel = this.getTabPanel();     

        // Open tab only if the menu node is a leaf node 
        if (clickedMnuNode.isLeaf()) { 
         tabPanel.add({ 
          xtype: clickedMnuNode.raw.loadTabComponent 
         }).show(); 
        } 
       } 
      } 
     }); 

     this.callParent(); 

    } 
I've는 "클릭"이벤트 리스너를 추가 한 컨트롤러에서

Ext.define('LT.store.MnuApplication', { 
    extend: 'Ext.data.TreeStore', 
    root: { 
     expanded: true, 
     children: [{ 
      text: "Lists", 
      expanded: true, 
      children: [{ 
       text: "Countries", 
       leaf: true, 
      }] 
     }] 
    } 
}); 

:

스토어 : 다음은 간단한 예입니다

이제이 솔루션에 대한 내 문제 : TreeStore에서 어떤 작업을 수행해야하는지 정의하고 싶습니다. 특히 어떤 구성 요소가로드되어야하는지 컨트롤러가 수행해야합니다.

예를 들어 나는 TreeStore이 보이는 것을 좋아하는 것 : 당신이 볼 수 있듯이

Ext.define('LT.store.MnuApplication', { 
    extend: 'Ext.data.TreeStore', 
    root: { 
     expanded: true, 
     children: [{ 
      text: "Lists", 
      expanded: true, 
      children: [{ 
       text: "Countries", 
       leaf: true, 
       loadComponent: 'country-list', 
       loadTarget: 'tabPanel' 
      }] 
     }] 
    } 
}); 

는 I've는 나무 잎에 두 개의 새로운 매개 변수를 추가했다. 이제 레코드의 "RAW"메소드를 통해 해당 데이터 세트에 액세스 할 수 없습니다. 그러나 그것은 정말로 좋은 해결책이 아닙니다. - 그렇지 않습니까?

그래서 저에게 TreeStore의 추가 매개 변수 (예 : "loadComponent"또는 "loadTaget")를 컨트롤러에 전달하는 방법에 대한 아이디어가 있습니까? 사전 & 환호에

덕분에, 과거 마이클

답변

0

나는 내 사용자 지정 매개 변수와 유사한 트리를 만들고 내 TreeStore에 대한 사용자 정의 모델을 사용했다. 기본적으로 노드에는 NodeInterface의 속성 만 있기 때문입니다. 다음과 같은 것 :

+0

나는 다음 노드 수준이 확장 노드를 기반으로로드되도록 노드의 guid를 TreeStore 프록시에 어떻게 전달합니까? – sambomartin

+1

모델에서 idProperty를 설정해야합니다. 프록시는 요청할 때이 속성을 사용합니다. –

+0

당신은 스타입니다! 간단합니다. 덕분에 – sambomartin

관련 문제