server-side processing: columns doesn't sort

server-side processing: columns doesn't sort

harold_crowharold_crow Posts: 11Questions: 2Answers: 0
edited December 2013 in General
Hello i am using version 1.9.4 with PHP and MySQL. The used script is generic for any table, so, i can tell it which columns has each table.

I have a little problem, i am using server side processing and works fine, but, when i try to sort with any column the table doesn't sort.

Researching and making tests i am not sure what happen, when i look into the answer of my php script (server side process) it returns the data sorted as i need but the table doesn't refresh this changes.

Notes: the table are sorted by the first columns asc always (the first time, i mean the query send the data sorted by the first column)

Here my code (it has some php code but it is the idea)
JS Code:
[code]
$(document).ready(function() {
$('#<?=$bunshin->nombre;?>').dataTable( {
"aaSortingFixed": [[ 0, "asc" ]],
"iDisplayLength": 10,
"bProcessing": true,
"bServerSide": true,
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "/datatables/copy_csv_xls_pdf.swf"
},
"sAjaxSource": "server_processing.php?admin_id=<?=$admin_id;?>",
"fnServerData": function( sUrl, aoData, fnCallback ) {
$.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "json",
"cache": false
} );
},
"iDeferLoading": <?=$numfilas;?>
});
})
[/code]
when i click on a column to sort, the variables sended to the server are
[quote]sSortDir_0 desc[/quote]

on the second time i click on the column the variable has
[quote]sSortDir_0 asc[/quote]

When i check the query, the query is fine too, but i only see the label "Processing...." but the data doesn't sort, what can i do?


I can't send you a link because this is an admin panel an it is not public yet... but if you need more info i will be glad to share it.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Since you have server-side processing enabled, it is the server which must to date sorting. If the "Processing..." label doesn't disappear then there might be an error in the returned data. We would need a test case to be able to say what is wrong I'm afraid.

    Allan
  • harold_crowharold_crow Posts: 11Questions: 2Answers: 0
    Thank you for your comment Allan. The label disappear, i think the problem is other, the query return the data ordered right.

    I can give you access to the admin panel if you want only tell me how can i send you the access privately
  • harold_crowharold_crow Posts: 11Questions: 2Answers: 0
    here is my debug code: elaqux
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Thanks for the debug code. Unfortunately I can't see the JSON return since you override fnServerData . To PM me, click on my name above and then "Send message".

    Allan
  • harold_crowharold_crow Posts: 11Questions: 2Answers: 0
    Thank you very much Allan, i sent you a PM
  • harold_crowharold_crow Posts: 11Questions: 2Answers: 0
    Hello, after a month, i review this issue again and i found the problem an fix it (code error) and i want to share it, maybe it can help.

    The problem was on the file server_processsing.php (to process the ajax call)
    On my case, i was using the code of the example on this page

    [code]
    if ( isset( $GET['iSortCol_0'] ) )
    {
    //$sOrder .= ", ";
    for ( $i=0 ; $i
This discussion has been closed.