2012-05-24 8 views
1

콤보 상자와 관련된 데이터 정렬 문제가 있습니다.콤보 상자와 extjs의 정렬 순서가 잘못되었습니다

데이터 소스는 JSON입니다. 데이터는 SQL에서 정렬됩니다. (SQL)에 세트 JSON 결과를 생성하는 것은 잘 보인다 :

{"rows":[{"id":"TOT","txt":" Alle diagnosen"},{"id":"612","txt":"(acute) bloeding distale tract. digestivus*"},{"id":"042","txt":"(auto)-intoxicatie"},{"id":"402","txt":"(benigne) peptisch ulcus*"},{"id":"10","txt":"(bij)niertumor"},{"id":"652","txt":"(chorio)retinitis.. etc etc 

결과 데이터가 잘 보인다 (= JSON 결과로서 동일한 정렬 순서) 나 방화와 함께 점포를 검사 :

enter image description here

enter image description here

그것은 아니오 : 그러나 결과 콤보는 다른 (잘못된) 정렬 (처음 2가 확인됩니다)가 표시 값 또는 id 값으로 정렬되지 않았습니다. 거기에 분류기가 없습니다.

콤보 :

{ 
    xtype: 'combobox', 
    id: 'ComboDiag', 
    itemId: 'ComboDiag', 
    width: 280, 
    fieldStyle: '', 
    name: 'ComboDiag', 
    fieldLabel: 'Diagnose', 
    labelWidth: 90, 
    displayField: 'txt', 
    queryMode: 'local', 
    store: 'ComboDiagStore', 
    typeAhead: true, 
    valueField: 'id', 
    listeners: { 
     render: { 
      fn: me.onComboDiagRender, 
      scope: me 
     } 
    } 
} 

스토어 :

Ext.define('AppPitDash.store.ComboDiagStore', { 
    extend: 'Ext.data.Store', 
    alias: 'store.ComboDiagStore', 
    requires: [ 
     'AppPitDash.model.ComboDiagModel' 
    ], 

    constructor: function(cfg) { 
     var me = this; 
     cfg = cfg || {}; 
     me.callParent([Ext.apply({ 
      autoLoad: true, 
      storeId: 'ComboDiagStore', 
      model: 'AppPitDash.model.ComboDiagModel', 
      proxy: { 
       type: 'ajax', 
       url: './php/get-data-diagCombo.php', 
       reader: { 
        type: 'json', 
        root: 'rows' 
       } 
      } 
     }, cfg)]); 
    } 
}); 

모델 : 나는 센차 아키텍트 2, 처음 사용하고

Ext.define('AppPitDash.model.ComboDiagModel', { 
    extend: 'Ext.data.Model', 

    fields: [ 
     { 
      name: 'id' 
     }, 
     { 
      name: 'txt' 
     } 
    ] 
}); 

.

이것은 쇼 스트 스토퍼보다 다소 귀찮은 일이지만 여전히 도움이 될 것입니다.

답변

1

스토어 정의에서 remoteSort: true ~ callParent 메서드를 추가하십시오.

0

는 사용해보십시오 : 나는 당신의 코드를 추가

remoteGroup: true, 
remoteSort: true, 
sortInfo: { field: 'order', direction: 'DESC' }, 
+0

(다른 필드로) 내 가게에, 그러나 그것은 작동하지 않았다. –

관련 문제