add another column to the returned json

add another column to the returned json

dreams1981dreams1981 Posts: 5Questions: 0Answers: 0
edited February 2011 in General
I have the same problem as http://datatables.net/forums/comments.php?DiscussionID=1581&page=1(how to put out content in a column what is not from the DB).
Allan said: in that section will add another column to the returned json.
[code]$sOutput .= '"column value",';[/code]
But I still don't know how to add another column to the returned json!
[code]
var oTable = $('table').dataTable({
bPaginate: true,
bProcessing: true,
sAjaxSource: "WebService1.asmx/GetData",
fnServerData: function ( sSource, aoData, fnCallback ) {
$.ajax({
"dataType": "json",
"type": "POST",
"url": sSource,
"success": fnCallback
});
}
});
[/code]

Replies

  • compcentralcompcentral Posts: 40Questions: 0Answers: 0
    $sOutput needs to be modified in you server side script before it is passed back to the DataTable. Using the "server_processing.php example script, you would insert that line of code before "echo json_encode($output);"
  • dreams1981dreams1981 Posts: 5Questions: 0Answers: 0
    oh,i just want to add any extra columns (add/edit/delete etc) to the table.
  • tehgreedotehgreedo Posts: 7Questions: 0Answers: 0
    Have you changed the $aColumns array to include the extra columns?

    [code]
    /* Array of database columns which should be read and sent back to DataTables. Use a space where
    * you want to insert a non-database field (for example a counter or static image)
    */
    $aColumns = array( 'url', 'notes', '" "', 'ticket_id' );
    [/code]

    I was having issues with including extra columns until I added the double quotes inside the single quotes.
This discussion has been closed.