yadcf - multi_select with select2 - 选项下拉列表不区分大小写

时间:2017-02-07 11:02:11

标签: datatables yadcf

在yadcf multi_select过滤器中是否可行,在不区分大小写的情况下对可能的选项进行排序?

以下是我的fiddle来解释这一点。

在列STATUS中有4个可能的值:" abs"," off"," OFF"和" ON"。在下拉列表中,选项按以下顺序显示:" OFF"," ON"," abs"," off"。我的愿望是按以下顺序显示选项:" abs"," OFF"," off"," ON"。

Thanks in advance one more time.

1 个答案:

答案 0 :(得分:2)

您可以提供自己的自定义排序功能,使用列sort_as: 'custom', sort_as_custom_func: mySort的以下属性(其中mySort是排序功能,如此

'use strict';

var oTable = $('#example').DataTable();
var mySort = function(a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
};
yadcf.init(oTable, [
    {
        column_number: 0,
        filter_type: 'multi_select',
        filter_match_mode: 'exact',
        select_type: 'select2',
        sort_as: 'custom',
        sort_as_custom_func: mySort
    },{
        column_number: 1,
        filter_type: 'text',
    }
]);

working jsfiddle