0

내 프로젝트에서 국가를로드하려면 select fiield를 사용하고 있습니다. 데이터베이스에서 데이터를로드합니다. 내 저장소에서 autoload : true를 사용할 때 완벽하게 작동합니다. 그러나 autoload : false를 사용할 때로드되지 않고 수동으로로드됩니다.Sebcha Touch Select 필드 로딩 문제

샘플 코드가 첨부되어 있습니다.

미리 감사드립니다.

스토어

Ext.define("MyProject.store.CountryStore", { extend: 'Ext.data.Store', 
    storeId: "countryStore", 
    config: { 
     model: "MyProject.model.CountryModel", 
     autoLoad: false, //this is the issue 
     header: { 
      "Content-Type": "application/json" 
     }, 
     proxy: { 
      type: 'ajax', 
      url: MyProject.Config.config.webService + 'GetCountries', 
      //extraParams: { 
      // sessionId: sessionId 
      //}, 
      reader: { 
       type: 'json', 
       rootProperty: 'd.countries' 
      }, 
      actionMethods: { 
       create: 'POST', 
       read: 'POST', 
       update: 'POST', 
       destroy: 'POST' 
      }, 
      writer: { 
       encodeRequest: true, 
       type: 'json' 
      } 
     } 
    } 
}); 

컨트롤러

var CountryStore = Ext.create('MyProject.store.CountryStore', {       }); 


      CountryStore.getProxy().setExtraParams({ 
       sessionId: sessionId 
      }); 
      CountryStore.load({ 
      }); 

보기

{    xtype: 'selectfield', 
       name: 'country', 
       label: 'Country', 
       store: 'CountryStore', 
       valueField: 'code', 
       displayField: 'name', 
       placeHolder: 'Select your country' 
} 

모델

Ext.define("MyProject.model.CountryModel", { 
    extend: 'Ext.data.Model', 
    config: { 
     idProperty: 'Id', 
     fields  : [ 
      { name: 'code'}, 
      { name: 'name'} 
     ] 
    } 
}); 

답변

0

상점을 이름으로 설정할 때 제어기의 상점을 사용하며, 제어기의 모든보기에 대한 전역 저장소입니다. 사용자 정의 저장소를 사용하려면보기에 전달해야합니다.

Ext.define('YourProject.controller.YourController', {  
    ... 

    sessionId: 'someId', 

    init: function() { 
     var me = this; 

     me.control({ 
      scope: me, 

      'yourviewname': { 
       afterrender: me.onViewAfterRender 
      } 
     }); 

     me.callParent(arguments); 
    }, 

    onViewAfterRender: function(view) { 
     var store = view.getStore(); 

     if (store) { 
      store.getProxy().setExtraParams({ 
       sessionId: sessionId 
      }); 

      store.load(); 
     } 
    } 

    ... 
}); 

Ext.define('YourProject.view.YourView', { 
    ... 
    alias: 'widget.yourviewname', 
    requires: ['YourProject.store.CountryStore'], 

    initComponent: function() { 
     var me = this, 
      countryStore = Ext.create('YourProject.store.CountryStore', {}); 

     Ext.applyIf(me, { 
      ... 

      items: [ 
       { 
        xtype: 'selectfield', 
        name: 'country', 
        label: 'Country', 
        store: countryStore, 
        valueField: 'code', 
        displayField: 'name', 
        placeHolder: 'Select your country' 
       } 
      ] 
     }); 
    } 
}); 
+0

빠른 답장을 보내 주셔서 감사합니다. 그것을 할 다른 방법이 없습니까? 내 시각을 깨끗하게 유지해야하기 때문에 (어떤 기능도없이). 어쨌든 컨트롤러에서 그렇게하지 않습니까? – Kasun

+0

컨트롤러에 비즈니스 로직을 추가하십시오. –

+0

맞습니다. 나는 또한 그렇게 할 것입니다. 고맙습니다. – Kasun

0

는 내가 컨트롤러에서 가게를 설정 작동 :

myView.items.items[9].setStore(CountryStore) 때 마침내

을 :) 해결;