Search code examples
datatablesyadcf

yadcf - multi_select with select2 - options dropdown not case sensitive


Will be posible, in yadcf multi_select filter, sort possible option with case insensibility?

Here is my fiddle to explain this.

In column STATUS are 4 possible values: "abs", "off", "OFF" and "ON". In dropdown the options appears in this order: "OFF", "ON", "abs", "off". And my desire is the options appears in this order: "abs", "OFF", "off", "ON".

Thanks in advance one more time.

Solution

  • You can provide you own custom sort function, , use the following attributes for the column sort_as: 'custom', sort_as_custom_func: mySort (where mySort is a sorting function, like this

    '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