DEV Community

Manish Chaudhary
Manish Chaudhary

Posted on

To Sort a column in datatable by another hidden column

I faced the issue of sorting date column format(‘m/d/Y H:i A’) (index: 0) when there are multiple years in data, and the work around I came up with is to create a new hidden field with date format Y-m-d H:i:s and updated the code as below

    'columnDefs': [
        { 'orderData':[1], 'targets': [0] },
            'targets': [1],
            'visible': false,
            'searchable': false
    "order": [[0, "asc"]],
    "oLanguage": {
        "sEmptyTable": "There are no transactions."
Enter fullscreen mode Exit fullscreen mode

Top comments (0)