When I apply DataTables to the following:
<td class="years"><?php $years."-years" ?></td>
<td class="..." ...
... other <td> ...
my table displays as follows:
10-years ... ... ...
10-years ... ... ...
5-years ... ... ...
7-years ... ... ...
9-years ... ... ...
because of the alphabetic ordering. I need 10-years
to appear at the bottom. To do that I added <td class="hidden"><?php $years ?></td>
right after <td class="years"><?php $years."-years" ?></td>
and added "order": [ 1, 'asc' ]
to the datatable initialization:
$(".table-rates").DataTable( {
"order": [ 1, 'asc' ]
});
after which it stopped working and started reporting an error in the console: "Cannot read property 'mData' of undefined".
Can someone explain how I can sort by a hidden column in my DataTables? I looked up online, but the solutions did not work for me. Even worse, the syntax is extremely confusing and hard to follow. Any help would be appreciated. Thanks!