Sort by Last Name
Sort by Last Name
Hi Guys, i'm trying to switch from tablesorter to Datatables because it has more features like filtering! But i am not able to sort a column with First and Last Name in it. It should be sorted by Last Name.
With the tablesorter plugin i adden an invisible span with numbers and sorted them (data is sorted by last name out of the mysql database). I tried this solution with datatables but failed. Any help would be appreciated.
Greetings Frank
With the tablesorter plugin i adden an invisible span with numbers and sorted them (data is sorted by last name out of the mysql database). I tried this solution with datatables but failed. Any help would be appreciated.
Greetings Frank
This discussion has been closed.
Replies
1) include a column for the last names, you can hide it with DataTables using bVisible in a column definition, but use it to sort by
2) in your server side code, detect when they're sorting by name, then have your ORDER BY clause reflect this
http://www.chogger.de/try.png
My code:
[code]
$(document).ready(function() {
$('#table').dataTable( {
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"bAutoWidth": false,
"aoColumns": [
{ "sType": "numeric" },
null,
null,
null,
null
] } );
} );
[/code]