Column Ordering (Ascending or Descending)
Column Ordering (Ascending or Descending)
hemant_joshi
Posts: 13Questions: 7Answers: 0
I am currently using server side Ajax source as data. I have tried bSortable:true. But it does not seem to order data on the client side. I am Not sure whether I would need to do ordering on the server side.
Is it possible to do orderning on client side even with Ajax Source possible?
This discussion has been closed.
Answers
So you need to put in something like this?
You can also set this up to sort based on multiple criteria one after another.
Best to make it to a 2D array. i.e.
[[ 0, 'desc' ]]
.Having said that, it should sort by default. if it is not, please link to a test case showing the issue.
Allan
You mean "order": [[0,"asc"], [1,"desc"]],
I tried but id did not work.
If you wanted a default of two columns sorting, then yes you could use that form.
As I noted:
Allan
$('#OTP_ADD_CANDIDATE_IN_DEPARTMENT_TABLE_ID').dataTable( {
"sPaginationType":"full_numbers",
"bDeferRender": true,
"bProcessing" : true,
"bServerSide" : true,
"bLengthChange" : false,
"iDisplayLength" : 10,
"lengthMenu": [[10,10,20,40,50], [10,10,20,40,50]],
"bSort":false,
"bFilter": true,
"saveState":true,
"sAjaxSource" : "/oltapp/showCandidates",
"order": [[0,"asc"],[1,"desc"]],
"sDom": '<"ui-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"<"toolbar">lfr>t<"ui-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"ip>',
"aoColumns" : [
I have this setup, please correct me where I am wrong. Many Thanks
You have enabled server-side processing, in which case the sorting should be done by your server-side script (
showCandidates
) as per the manual.Allan
I have removed server side processing, then it has issues with Ajax call. I am not sure what is the syntax for Ajax call for server side data but ordering on the client side.
Examples available here.
Allan