mercredi 20 juillet 2016

jQuery Datatable custom sort

Hey guys so i got this datatable

var oTable = $("#products").dataTable({
    "aaData": [
        [1, "TEST1", "A"],
        ['NA', "NA1", "B"],
        ['NA', "NA2", "C"],
        [4, "TEST2", "D"]
    ],
    "aoColumns": [{
        "sWidth": "70%",
        "sClass": "center",
        "bSortable": true,
        "sType": "rankedNA"

    }, {
        "sWidth": "70%",
        "sClass": "center",
        "bSortable": false
    }, {
        "sWidth": "70%",
        "sClass": "center",
        "bSortable": false
    }]

});

I need a custom sort

    jQuery.fn.dataTableExt.oSort['rankedNA-asc']  = function(a, b) {
        return rankedNASort(a, b);
    };

That always leaves the 'NA' values in the first column at the bottom of the table. No matter if its asc or desc, NA should be fixed at the bottom

Aucun commentaire:

Enregistrer un commentaire