Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Datatables plugin - aoData, where it comes from and how

Looking at the "fnServerCallback" function parameter when initialising a Datatable, is there a way to know or set the "aoData" variable? Where is this variable set? Can I change the "name" attribute inside the array of objects?

I am asking this because knowing how aoData is set might prove useful when trying to pass data to a server.

like image 369
developarvin Avatar asked Aug 30 '11 10:08

developarvin


2 Answers

You can get access to aoData at any time by using fnSettings() (you can check its description here) function. Inside returned settings there is aoData object ready for you.

var oTable;
$(document).ready(function() {
    oTable = $('#example').dataTable();
    var oSettings = oTable.fnSettings();

    /* Show an example parameter from the settings */
    alert( oSettings.aoData );
} );
like image 129
WTK Avatar answered Nov 09 '22 23:11

WTK


What exactly do you need to do?If you need to pass additional data to a server you can look at this example

EDIT - i found out this:

  1. aoData is a name / value array of variables which jQuery will take and send to the server, so you can read them as POST (or GET if you elect to use that) variables.

  2. You have "name" and "value" parameters defined twice in the same object... Try:

    aoData.push( { "name": "blah", "value": "blahblah" } ); aoData.push( { "name": "thing", "value": "thingsvalue" } );

like image 33
Nicola Peluchetti Avatar answered Nov 10 '22 01:11

Nicola Peluchetti