Custom Order on Server-Side
Custom Order on Server-Side
Hi!, first at all thanks a lot for this great plugin.
I'm having problems to understand how to change the order of columns on server-side.
I have readed this: http://datatables.net/examples/server_side/column_ordering.html but i just cant do it...
This is my script:
[code]
var oTable =$('#lista').dataTable( {
"bProcessing": true,
"iDisplayLength": 10,
"sDom": '<"top">rt<"paginas"p><"clear"><"hidden"f>',
"sPaginationType": "full_numbers",
"bServerSide": true,
"aaSorting": [[ 1, "desc" ]],
"sAjaxSource": "/Sources/table.php",
"aoColumnsDefs": [
{ "mData": "name", "aTargets": [0]},
{ "mData": "promedio", "aTargets": [1] },
{ "mData": "pais", "aTargets": [2] },
{ "mData": "tipo", "aTargets": [3] }
],
"fnServerData" : function ( sSource, aoData, fnCallback ) {
aoData.push(
{ "name": "id_cat", "value": "<?php echo $idcat?>" },
{ "name": "dato1", "value": $('#dato1').is(":checked") },
{ "name": "dato2", "value": $('#dato2').is(":checked") },
{ "name": "tipo1", "value": $('#tipo1').is(":checked") },
{ "name": "tipo2", "value": $('#tipo2').is(":checked") },
{ "name": "habilitado", "value": 1 }
);
// send request to server, use default fnCallback to process returned JSON
$.ajax( {
"dataType": 'json',
"url": sSource,
"data": aoData,
"success": fnCallback
} );
[/code]
And "table.php" :
[code]
$output = array(
"sEcho" => intval($_GET['sEcho']),
"iTotalRecords" => $iTotal,
"iTotalDisplayRecords" => $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
I'm having problems to understand how to change the order of columns on server-side.
I have readed this: http://datatables.net/examples/server_side/column_ordering.html but i just cant do it...
This is my script:
[code]
var oTable =$('#lista').dataTable( {
"bProcessing": true,
"iDisplayLength": 10,
"sDom": '<"top">rt<"paginas"p><"clear"><"hidden"f>',
"sPaginationType": "full_numbers",
"bServerSide": true,
"aaSorting": [[ 1, "desc" ]],
"sAjaxSource": "/Sources/table.php",
"aoColumnsDefs": [
{ "mData": "name", "aTargets": [0]},
{ "mData": "promedio", "aTargets": [1] },
{ "mData": "pais", "aTargets": [2] },
{ "mData": "tipo", "aTargets": [3] }
],
"fnServerData" : function ( sSource, aoData, fnCallback ) {
aoData.push(
{ "name": "id_cat", "value": "<?php echo $idcat?>" },
{ "name": "dato1", "value": $('#dato1').is(":checked") },
{ "name": "dato2", "value": $('#dato2').is(":checked") },
{ "name": "tipo1", "value": $('#tipo1').is(":checked") },
{ "name": "tipo2", "value": $('#tipo2').is(":checked") },
{ "name": "habilitado", "value": 1 }
);
// send request to server, use default fnCallback to process returned JSON
$.ajax( {
"dataType": 'json',
"url": sSource,
"data": aoData,
"success": fnCallback
} );
[/code]
And "table.php" :
[code]
$output = array(
"sEcho" => intval($_GET['sEcho']),
"iTotalRecords" => $iTotal,
"iTotalDisplayRecords" => $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
This discussion has been closed.
Replies