2012-06-19 3 views
1

내 코드에 버그가 있지만 잘못된 점을 파악할 수 없습니다. NestedList의 리프 항목을 누를 때 저장소에 새 URL을 설정하려고합니다. 내 가게는 다음과 같습니다.Store의 프록시에서 URL을 설정하는 방법은 무엇입니까?

Ext.define('Application.store.DetailStore', { 
extend: 'Ext.data.Store', 

config: { 
    model: 'Application.model.DetailModel', 
    autoLoad :true, 
    sorters: 'title', 
    grouper : function(record) { 
     return record.get('title')[0]; 
     }, 

    proxy: { 
    type: 'ajax', 
    url : '/data/data1.php', 
    reader: { 
    type: 'json', 
    rootProperty:'recipes'} 
     } 
} 

}}); 내가 표시되지 않습니다 잎 항목 및 세부 카드에 탭 두지이 후

onLeafItemTap: function(nestedList, list, index, node, record, e) { 
    filter = record.get('text'); 
    var detailCard = nestedList.getDetailCard();  
    Ext.getStore('Application.store.DetailStore').getProxy().setUrl('/data/data2.php'); 
    Ext.getStore('Application.store.DetailStore').load() 
} 

:

는 그리고이 NestedList에서 leafitemtap 내 청취자입니다. 무엇이 잘못 될 수 있는지 아는 사람이 있습니까?

답변

0

아래에서는 리프 항목을 두드리고 저장소를로드 할 때 getMain 메서드를 사용하여 목록 맨 위에있는 detailCard를 밀어 넣었습니다. 나는 또한 귀하의 컨트롤러에 refitemtap 로직을 정의하고 있다고 가정하고 ref로 getMain을 사용합니다.

당신은 대신 "Application.store.DetailStore"당신이 가게를 설정 할 수 및로드 할 모든 그냥 쓰는 경우 질문을 통해 다시 읽기

 Ext.getStore('Application.store.DetailStore').setProxy({ 
     type: 'ajax', 
     url: '/data/data2.php' 
    }).load({ 
     callback: function(records, operations, success) { 
      if (success = true) { 
       this.getMain().push({ 
        xtype: 'detailsCard', 
        data: record.getData() 
       }) 
      } else { 
       Ext.Msg.alert('Error', 'Something went wrong!', Ext.emptyFn); 
      } 
     }, 
     scope: this 
    }); 
+0

의에 storeId를 사용할 수 있습니다 Ext.getStore (' ( 형식 : 'ajax', url : '/data/data2.php') .getProxy 및 setUrl 대신 load() –

+0

답장을 보내 주셔서 감사합니다! 하지만 도움이되지 않습니다, 나는 여전히 리프 항목을 탭 수 없습니다. Ext.getStore ('Application.store.DetailStore') 뒤에 무언가를 썼을 때 코드의 일부분을 삭제하고 테스트를 마쳤습니다. –

+0

NestedList 뷰, 모델 및 상점에서 가져 오는 JSON을 게시 할 수 있습니까? –

관련 문제