2012-05-24 38 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

然而,得到的組合框具有不同的(錯誤的)排序(第一2是OK):

enter image description here

這是沒有t按顯示值排序,也不按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)]); 
    } 
}); 

型號:

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

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

我使用煎茶建築師2,第一次。

這是一個比showstopper煩惱,但仍然幫助將不勝感激。

回答

1

嘗試在商店定義中添加remoteSort: truecallParent方法。

0

嘗試使用:

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

我加了你的代碼(用不同的字段)到我的商店,但沒有奏效。 –