Problems iSortCol_0 and iSortDir_0 in Server-Side

Problems iSortCol_0 and iSortDir_0 in Server-Side

pennismenpennismen Posts: 1Questions: 0Answers: 0
edited November 2012 in DataTables 1.9
$(document).ready(function() {
var oTable = $('#datatable').dataTable({
"bProcessing" : true,
"bServerSide" : true,
"bDeferRender" : true,
"sAjaxSource" : Routing.generate('mng_manager_clientslist'),
"iDisplayLength": 200,
"iScrollLoadGap": 150,
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollX" : "100%",
"sScrollY" : "569px",
"sScrollXInner" : "3000px",

"sPaginationType" : "full_numbers",
"sDom" : 'T<"clear">lfrtip',
"oTableTools" : {
"sRowSelect" : "single",
"aButtons" : []
},

"aoColumns" : [{
"sTitle" : "ID Cliente",
"mDataProp" : "idclients",
"sClass": "center"
}, {
"sTitle" : "Company Name",
"mDataProp" : "companyname",
"sDefaultContent": "",
"sClass": "left"
}, {
"sTitle" : "Direction",
"mDataProp" : "companydirection",
"sDefaultContent": "",
"sClass": "left"
}, {
"sTitle" : "Zip Code",
"mDataProp" : "companyzipcode",
"sDefaultContent": "",
"sClass": "center"
}, {
"sTitle" : "City",
"mDataProp" : "companycity",
"sDefaultContent": "",
"sClass": "center"
}, {
"sTitle" : "Province",
"mDataProp" : "companyprovince",
"sDefaultContent": "",
"sClass": "center"
}, {
"sTitle" : "C.I.F.",
"mDataProp" : "companycif",
"sDefaultContent": "",
"sClass": "center"
}, {
"sTitle" : "Phone",
"mDataProp" : "companyphone",
"sDefaultContent": "",
"sClass": "center"
}, {
"sTitle" : "Fax",
"mDataProp" : "companyfax",
"sDefaultContent": "",
"sClass": "center"
}, {
"sTitle" : "Mobile Phone",
"mDataProp" : "companymobile",
"sDefaultContent": "",
"sClass": "center"
}, {
"sTitle" : "E-Mail",
"mDataProp" : "companyemail",
"sDefaultContent": "",
"sClass": "left"
}, {
"sTitle" : "WebSite",
"mDataProp" : "companywebsite",
"sDefaultContent": "",
"sClass": "left"
}, {
"sTitle" : "Personal Name",
"mDataProp" : "personalname",
"sDefaultContent": "",
"sClass": "left"
}, {
"sTitle" : "Personal Mobile",
"mDataProp" : "personalmobile",
"sDefaultContent": "",
"sClass": "center"
}, {
"sTitle" : "Personal E-Mail",
"mDataProp" : "personalemail",
"sDefaultContent": "",
"sClass": "left"
}, {
"sTitle" : "Category",
"mDataProp" : "companycategory",
"sDefaultContent": "",
"sClass": "center"
}, {
"sTitle" : "Date",
"mDataProp" : "newclientday",
"sDefaultContent": "",
"sClass": "center"
}]

});
});

There are the key=>value in SERVER-SIDE

iSortCol_0 '0'
iSortingCols '1'
mDataProp_0 idclients
mDataProp_1 companyname
mDataProp_10 companyemail

--

$number = $this->request->request->get('sSortCol_0');
$name = $this->request->request->get('mDataProp_'.$number);
$final = $name;


$dq->orderBy("'{$this->entity_alias}'.'{$final}'", "{$this->request->query->get('sSortDir_0')}");


<!- $final = value of "mDataProp_0" = idclients

Datatables send correct by POST in server-side is imposible of get mDataProp_0 value. I try directly get mDataProp_0 but variable return NULL.

¿Who can help me?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Have you tried using this script: https://github.com/DataTables/DataTables/blob/master/examples/server_side/scripts/objects.php - it resolves mDataProp_{}. Even if you don't use that script directly it might prove instructive for you.

    Allan
This discussion has been closed.