sending custom parameter for DataTables

sending custom parameter for DataTables

tuxworldtuxworld Posts: 7Questions: 0Answers: 0
edited November 2012 in General
i can use this below code for getting results in server_side file, but i cant send any parameters such az sql query,fields for search, i want to create modular file for use single file in all projects . how to sending custom parameter for DataTables like with this code?
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "scripts/server_processing.php"
/*
"SQlQuery":"SELECT * FROM student",
"Columns" :" id , name , code"
*/
} );
} );
[/code]

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    > how to sending custom parameter for DataTables like with this code?

    Use fnServerParams to send extra data to the server.

    Allan
  • tuxworldtuxworld Posts: 7Questions: 0Answers: 0
    whats problem in this code:
    server_side.php
    [code]$aColumns = array("{$_POST['lgn']}",'member_id','first_name','last_name' );[/code]
    jQuery:[code]
    "sAjaxSource" : "server_processing.php",
    "fnServerParams": function ( aoData ) {
    aoData.push( { "lgn": "login"} );
    }
    [/code]
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    You need to use name/value pairs: http://datatables.net/release-datatables/examples/server_side/custom_vars.html
  • tuxworldtuxworld Posts: 7Questions: 0Answers: 0
    then must be change to this?
    [code]
    "sAjaxSource" : "server_processing.php",
    "fnServerParams": function ( aoData ) {
    aoData.push( { "name": "lgn","value":"login"} );
    }
    [/code]
    OK?
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Looks good to me :-)
This discussion has been closed.