Column Ordering (Ascending or Descending)

Column Ordering (Ascending or Descending)

hemant_joshihemant_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?

Answers

  • mRendermRender Posts: 151Questions: 26Answers: 13

    So you need to put in something like this?

    order: [ 0, 'desc' ],
    

    You can also set this up to sort based on multiple criteria one after another.

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin
    edited May 2015

    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

  • hemant_joshihemant_joshi Posts: 13Questions: 7Answers: 0

    You mean "order": [[0,"asc"], [1,"desc"]],

    I tried but id did not work.

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    If you wanted a default of two columns sorting, then yes you could use that form.

    As I noted:

    if it is not, please link to a test case showing the issue.

    Allan

  • hemant_joshihemant_joshi Posts: 13Questions: 7Answers: 0

    $('#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

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    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

  • hemant_joshihemant_joshi Posts: 13Questions: 7Answers: 0

    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.

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin
This discussion has been closed.