passing Id value on "server processing script"

passing Id value on "server processing script"

emelianenkoemelianenko Posts: 18Questions: 0Answers: 0
edited November 2010 in General
Hello,

In the server_processing script. How do you track and pass the value of the id, the primary key for example. Here

$sOutput .= '"'.addslashes($aRow['from_country']).'

if you have not tracked the value of id_staff it is like an empty variable. So, where and how do you actually keep track of it so that in that line it does pass a value.

The part of the script before that line is here below, the one that is like the template for Server Processing and it is here exposed. So what I am asking is not a unique thing, actually it is the very essential, that your column has a link so that you can click on it and pass a value to another page. Thanks a lot.

/*
* Output
*/
$sOutput = '{';
$sOutput .= '"sEcho": '.intval($_GET['sEcho']).', ';
$sOutput .= '"iTotalRecords": '.$iTotal.', ';
$sOutput .= '"iTotalDisplayRecords": '.$iFilteredTotal.', ';
$sOutput .= '"aaData": [ ';
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$sOutput .= "[";
for ( $i=0 ; $i

Replies

  • djlakesdjlakes Posts: 7Questions: 0Answers: 0
    This is done via pushing extra data. You do this in the location where you initialize your table.

    So if you've got a setup like this:
    [code]$('#table_id').dataTable({
    "bServerSide": true,
    "bProcessing": true
    });[/code]

    You'll want to add an additional parameter "fnServerData". This is an overwrite of the function called when requesting data from the server. See here: http://www.datatables.net/usage/callbacks for instructions on how to complete that. But in general, what you'd want is something like:

    [code]$('#table_id').dataTable({
    ...Other dataTable variables
    "fnServerData": function (sSource, aoData, fnCallback ){
    /*add some extra data to the sender*/
    aoData.push({ "name":"id_staff","value":<?php echo $aRow['id_staff'];?>});
    /*send it along for normal processing*/
    $.getJSON ( sSource, aoData, function (json) { fnCallback(json) } );
    }
    });

    Then in your server side script, you simply look for the variable $_GET['id_staff'].

    Hope that helps!
  • emelianenkoemelianenko Posts: 18Questions: 0Answers: 0
    Hello


    Thank you for that. Yes, I was familiar somewhat with the fncallbacks as I have a few scripts with them, but the server side processing script then goes a long different way than the one that is set by default in the Examples section for Server Side processing, and this is the one I am using this (line 159 of the provided script by Allan, referred to as Version line).

    That is, if I use the fncall back I have to redo a completely different script.

    There may be this shortcut:

    I can include all of the columns, included that of id_staff in here

    $aColumns = array( 'id_staff', etc

    and then yes definitively I have the id value and all I need to do is add it an
This discussion has been closed.