server side processing sending more data ?

server side processing sending more data ?

LoboLobo Posts: 9Questions: 0Answers: 0
edited May 2010 in General
Hi Allan,

There is a way to send more datas to the plugin via the json built by the server_side.php ?

An example to illustrate my point :
1- the user filter the table
2- the server send the json corresponding to the array of the filter and add extra datas at the json level of 'iTotalRecords'.
3- those extra datas could be e.g.: for the filter applied number of valid emails, number of valid mobile phones,... used to refresh a dedicated div

The only way i find to do my purpose was to modify your plugin js.

Example :
- adding in classSettings function :
[code]this.myparameter=0;[/code]
- adding in _fnAjaxUpdateDraw function
[code]oSettings.myparameter=json.myparameter; [/code]
- then :
[code] oTable = $('#Liste).dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "ajax/Listes/processListe.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"complete":function(){
log.info('fnServerData myparameter='+oTable.fnSettings().myparameter);
/*then i do what i want with myparameter*/
},
"success": fnCallback
} );
},...
[/code]

There is a better way on 1.6.2 ?

Otherwise it would be fine in 1.7 to have a way to had custom settings or things like this :-)

Thanks for the look.

Best regards.
Carlos

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Carlos,

    Do you mean something like this: http://datatables.net/examples/server_side/custom_vars.html

    Allan
  • LoboLobo Posts: 9Questions: 0Answers: 0
    edited May 2010
    Hi Allan,

    Your example send extra vars to the server.
    My goal is that the server send more vars not linked to the columns to the plugin DataTable on client side.
    see the "complete" function in $.ajax via fnServerData in the last code sample of my previous post.

    Thanks.
    Carlos
This discussion has been closed.