2015-01-22 1 views
0

내 트리 노드 선택에 따라 레코드를로드하고이를 내 양식에 표시하려고합니다. 그러나 내 저장소가 내 컨트롤러 처리기에로드되어 있지 않습니다. 매개 변수를 사용하여 상점을 어디서 어떻게로드해야합니까?동적 매개 변수가있는로드 스토어

Ext.define('TTT.store.Tag', { 
    extend: 'Ext.data.Store', 
    requires: [ 
     'TTT.model.Tag' 
    ], 
    model: 'TTT.model.Tag', 

    proxy: { 
     type: 'ajax', 
     url: 'tag/find.json', 
     reader: { 
      type: 'json', 
      root: 'data' 
     } 
    } 
    ,baseParams: { 
     idTag: 30 
    }, 
}); 

답변

1

당신은 필요할 때마다 수동으로로드 메서드를 호출하고 다음과 같이 매개 변수가 필요 전달할 수 있습니다 :

me.getTagStore().load({ 
    params: { 
     idTag: idTag 
    } 
}); 

이 당신을 호출 할 때

 var me = this; 
     var idTag= me.getMyNode(); 
     me.getTagStore().on('beforeload', function(store, operation, eOpts) { 
      operation.params = { 
       idTag: idTag 
      }; 
     }, me); 
     // it will not be loaded here and I get rec=undefined 
     var rec = me.getTagStore().load().getAt(0); 
     me.getMyForm().loadRecord(rec); 

그리고 여기 내 가게 브라우저의 콘솔 창에있는 매개 변수로 요청을보아야합니다. 위의 코드에서

,이 라인 :

// it will not be loaded here and I get rec=undefined 
var rec = me.getTagStore().load().getAt(0); 

로드 작업이별로 약간의 시간이 필요하지만 약간의 시간이 걸릴 않습니다.

me.getTagStore().load({ 
    params: { 
     idTag: idTag 
    }, 
    scope: this, 
    callback: function(records, operation, success) { 
     // the operation object 
     // contains all of the details of the load operation 
     console.log(records); 
    } 
}); 

체크 아웃 store에 대한 설명서 :이 같은 일을 할 수 있도록 상점에있는로드 이벤트를 수신 할 필요가 여기에 예입니다.