【问题标题】:mixed sorting in extjs gridextjs网格中的混合排序
【发布时间】:2023-03-27 14:19:01
【问题描述】:

我想根据文本和数字对列进行排序。

我的值是这样排序的:

- List:010
 - List:100
 - List:134
 - List:2
 - List:204

但我需要的是

- List:2
 - List:010
 - List:100
 - List:134
 - List:204

我使用的列类型是字符串。我尝试使用 sortType 但那不起作用。

{
            name: 'listItems',
            type: 'string',
            mapping: 'listItems'
        }

【问题讨论】:

    标签: sorting extjs types grid


    【解决方案1】:

    如果您使用的是 ExtJS 4.x,则可以利用 SortTypes 类。

    Ext.apply(Ext.data.SortTypes, {
        asPerson: function(person){
            // expects an object with a first and last name property
            return person.lastName.toUpperCase() + person.firstName.toLowerCase();
        }    
    });
    
    Ext.define('Employee', {
        extend: 'Ext.data.Model',
        fields: [{
            name: 'person',
            sortType: 'asPerson'
        }]
    });
    

    更多信息on the SortTypes doc page

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多