2012-02-02 2 views
0

json 파일을로드하려고 할 때 Sencha Touch selectfield에서 실제로로드 할 값을 얻는 데 문제가 있습니다.Sencha Touch의 selectfield에 json 데이터 추가

Ext.regModel('d', { 
fields: [{ 
      name: 'Name', type: 'string' 
     }, { 
      name: 'id', type: 'int' 
     }] 
}); 

Ext.regStore('TempStore', { 
    model: 'd', 
    autoLoad: true, 
    proxy: { 
     type: 'ajax', 
     url: '/sampledata.json', 
     reader: { 
      type: 'json', 
      root: 'd' 
     } 
    } 
}); 

items: [{ 
      xtype: 'selectfield', 
      label:'My Field', 
      id: 'Test', 
      name: 'Name', 
      store: 'TempStore', 
      displayField: 'Name', 
      valueField: 'id', 
      placeHolder: 'Select a Value' 
     } 

내가의 .js 파일과 같은 폴더에 samepledata.json 파일을 가지고 있고, 페이지가로드 미세하지만 난 selectfield을 누르면이 함께 제공됩니다

내 코드의 관련 부분은 빈 목록.

아이디어가 있으십니까?

편집 : 오타

답변

0

상점 이름에 따옴표를 제거하십시오.

items: [{ 
      xtype: 'selectfield', 
      label:'My Field', 
      id: 'Test', 
      name: 'Name', 
      store: TempStore, //No quotes here. 
      displayField: 'Name', 
      valueField: 'id', 
      placeHolder: 'Select a Value' 
     } 

항목 :

{ 
    xtype: 'selectfield', 
    label: 'Cuenta', 
    name: 'cuenta', 
    store: 'TipoPago', 
    displayField: 'name', 
    valueField: 'name', 
} 

그리고 그것은 완벽하게 작동합니다 : Sencha Touch SelectField API

+0

흠, 시도해 보니 페이지가로드되지 않습니다. – Calvin

+0

대신 Ext.regstore를 시도하십시오. var TempStore = new Ext.data.Store ({model : 'd', autoLoad : true, proxy : .....}); – riship89

+0

흠, 아직 작동하지 않습니다. (라이브 예제의 경우 http://selectout.net/oil/app/을 확인한 다음 왼쪽에있는 데이터 추가를 클릭하고 상단에 예고편 설정을 클릭하면 해당 필드가있는 페이지로 이동합니다). 도움에 감사드립니다. 정말 고맙습니다. – Calvin

0

글쎄, 나는이 작업을 수행. 물론 에 대한 모델 및 상점이 이미 정의되어 있습니다. myapp.store.TipoPagomyapp.model.TipoPago입니다.

관련 문제