2015-01-06 2 views
0

저장소는 별도 기능으로 bindStore를 사용하여 콤보 상자에 연결됩니다.콤보 상자 및 bindStore에 대한 필터링 저장

모든 매개 변수를 기반으로 해당 함수의 데이터를 필터링해야합니다.

loadMarkers: function(store, value){ 

    store.filter('markerid',17); 

    this.fields.marker.bindStore(store); 
    this.fields.marker.setValue(value); 
    } 

이 구체적인 예에는 바인딩 전과 후에 두 가지 diff 방법이 있습니다. 마지막 Console.log는 'store'와 심지어 combobox에 대한 필터링 된 저장소를 보여줍니다. 그러나 콤보 박스 자체는 여전히 모든 것을 보여줍니다.

콤보 상자의 설정 :

marker: new Ext.form.ComboBox({ 
    fieldLabel: _('Marker'), 
    displayField: 'name', 
    valueField: 'id', 
    mode:'local', 
    lastQuery: '', 
    store: new Ext.data.JsonStore({ 
     fields: ['name', 'id', 'markerid'], 
     data: [ 
     {name:_('Default'), id: 0, markerid: 0} 
     ] 
    }) 
    }) 

this.markerStore = new Ext.data.JsonStore({ 
    autoLoad: true, 
    url: 'Api/getMarkers', 
    root: 'response', 
    sortInfo: {field: 'name', direction: 'ASC'}, 
    fields: Ext.data.Record.create([ 
    {name: 'id', type: 'integer'}, 
    {name: 'name', type: 'string'}, 
    {name: 'markerid', type: 'integer'} 
    ]) 
}); 
+0

당신은 상점 설정이 너무 – Scriptable

+0

당신이 친구를 사용하는 내선의 버전을 저장 설정 –

+1

업데이트 보여줄 수 있을까요? 나는 최소한 – Scriptable

답변

1

나는 당신으로 인해 위의 코드의 형식이 답변의 ExtJS 3.4을 사용하고있는 것으로 추정하고있다.

직접 코드를 실행하려고 시도했지만 많은 오류가 발생했습니다. _('Default') _() is undefined과 같은 문서에서 ComboBox에는 bindStore ComboBox Documation이라는 함수가 없습니다.

아래의 코드에 코드를 다시 작성했으며 제대로 작동합니다. 저장소에서 데이터를로드 한 후 필터를 적용하고 있는지 확인해야합니다. 예를 들어로드 이벤트가 발생하기를 기다립니다.

Ext.onReady(function() { 

    Ext.BLANK_IMAGE_URL = '/js/ext-3.4.0/resources/images/default/s.gif'; 

    var markerStore = new Ext.data.JsonStore({ 
     autoLoad: true, 
     url: 'data/data1.json', 
     root: 'rows', 
     sortInfo: {field: 'name', direction: 'ASC'}, 
     fields: [ 
      {name: 'id', type: 'integer'}, 
      {name: 'name', type: 'string'}, 
      {name: 'markerid', type: 'integer'} 
     ], 
     listeners: { 
      'load': function() { 
       Ext.getCmp('createformTypeCombo').getStore().filter('markerid', 17); 
      } 
     } 
    }); 


    var form = new Ext.form.FormPanel({ 
     renderTo: Ext.getBody(), 
     items: [ 
      new Ext.form.Label({ 
       text: "form", 
       margin: "25 10 25 5" 
      }), 
      new Ext.form.ComboBox({ 
       fieldLabel: 'Marker', 
       id: 'createformTypeCombo', 
       displayField: 'name', 
       valueField: 'id', 
       mode:'local', 
       lastQuery: '', 
       store: markerStore 
      }) 
     ] 
    }); 
}); 
+0

에 _ ('Default')와 같은 코드를 게시 할 것이다. - 무시할 수 있으며 _()는 번역 스크립트의 특수 태그이다. 또한 bindStore는 비공개입니다 (기본적으로 표시하지 않습니다). 최종 필터 값이 동적이고 함수의 매개 변수로 제공되기 때문에로드 이벤트에 필터를 추가 할 수 없습니다. 저장소가 한 번로드 된 후 필요한 결과가 나중에 필터링되어 서버 및 db에 과도한 쿼리가 발생하지 않습니다. –

+0

좋아요,로드 이벤트에 필터를 추가하려고하면 문제가 해결 될 것입니다. – Scriptable

관련 문제