【问题标题】:ExtJS 5.0 : Grid remoteSort always sorts by the default 'sorters' onlyExtJS 5.0:Grid remoteSort 始终仅按默认的“排序器”排序
【发布时间】:2018-02-02 18:57:54
【问题描述】:

我有一个带有缓冲存储的 EXTJS 网格。我在这家商店启用了 remoteSort: true。有几个列被标记为可排序的: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
    }]
});

我怎样才能让这个网格按点击的任何可排序的列排序?

【问题讨论】:

    标签: javascript sorting extjs grid store


    【解决方案1】:

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

    你已经设置了第一个排序器,通过列点击排序在它后面添加了第二个排序器,但是当simpleSortMode被激活时,只有第一个排序器被发送到服务器。

    【讨论】:

    • 感谢您的更正。我删除了 simpleSortMode: true ,但我仍然看到同样的问题。使用 remoteSort: true 和提到的排序器,按列单击排序仍然只使用排序器。我还尝试了 remoteSort: false (仅启用本地排序)并且完全禁用排序。
    • 您能提出一个解决方案吗?
    • I have made a Sencha fiddle 发现原因是5.0.0的问题。该错误已在 5.0.1 中修复,您应该考虑升级框架。
    • 谢谢!我确实认为这可能是一个 ExtJS 问题。我会研究升级。顺便说一句,是否可以只使用本地排序?
    【解决方案2】:

    临时修复 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);
        }
    });  
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-22
      • 1970-01-01
      • 1970-01-01
      • 2012-12-15
      • 2011-09-28
      • 1970-01-01
      相关资源
      最近更新 更多