ExtJS 5.0:Grid remoteSort 始终仅按默认 'sorters' 排序

ExtJS 5.0 : Grid remoteSort always sorts by the default 'sorters' only

我有一个带有缓冲存储的 EXTJS 网格。我在这家商店启用了 remoteSort: true。一些列被标记为可排序:真。但是每次我点击任何列进行排序时,进行的后端调用只包括商店中提到的排序列和方向。前任。即使我点击 Col2 或 Col3 进行排序,GET 调用后端总是包含 'sort: col1, direction: desc',如 'sorters'.

中所述

商店:

Ext.define('MyStore', {
  extend: 'Ext.data.BufferedStore',
 model  : 'MyModel'

  pageSize: 200,
  autoLoad: false,
  leadingBufferZone: 200,
  trailingBufferZone: 200,
  remoteSort: true,
  sorters: [{
    property: 'col1',
    direction: 'DESC'
  }],

  proxy: {
    type  : 'rest',
    format: 'json',
    url   : '/my_app/my_controller/list',
    extraParams: {
      someparam: '',
      otherparam: ''
    },
    reader: {
      type: 'json',
      rootProperty: 'data',
      totalProperty: 'totalCount'
    }
  }  
});

网格:

Ext.define('MyPanel', {
    extend: 'Ext.grid.Panel',
    requires: [
    'MyStore'
    ],
    initComponent: function() {
        this.store = new MyStore();
        this.callParent(arguments);
    },
    columns: [{
        text: 'Col1',
        dataIndex: 'col1',
        width: 150,
        sortable: true
    },{
        text: 'Col3',
        dataIndex: 'col3',
        width: 150,
        sortable: true
    },{
        text: 'Col3',
        dataIndex: 'col3',
        width: 250,
        sortable: true
    }]
});

如何使此网格能够按单击的任何可排序列进行排序?

您已明确设置 simpleSortMode,文档中已经提到了问题所在。

您已经设置了第一个排序器,按列点击排序会在其后添加第二个排序器,但在simpleSortMode激活时只会将第一个排序器发送到服务器。

临时修复了 ExtJS 5.0 中的错误。参见:https://www.sencha.com/forum/showthread.php?284772-remoteSort-doesn-t-work-with-BufferedStore

Ext.override(Ext.data.BufferedStore, { 
     sort: function(column, direction, mode){      
      this.getSorters().addSort(column, direction, mode);
      this.callParent(arguments);
    }
});