Skip to content Skip to sidebar Skip to footer

How Do I Sort By A Hidden Column In Datatables?

When I apply DataTables to the following: ... my table displays as fo

Solution 1:

It's innecesary add other column, you can use data-attributes of datatable, add in your html code data-order:

<tdclass="years"data-order="<?php$years?>"><?php$years."-years"?></td>

And your code JS:

$(document).ready(function() {
    $('#example').DataTable({
        "order": [ 0, 'asc' ]
    });
});

Result:https://jsfiddle.net/cmedina/7kfmyw6x/69/

Post a Comment for "How Do I Sort By A Hidden Column In Datatables?"