programmatically send data from external form

programmatically send data from external form

thunderrabbitthunderrabbit Posts: 7Questions: 0Answers: 0
edited April 2012 in DataTables 1.8
I'm using DataTables 1.8.2 to pull data from my server via ajax. The columns include a date field.

Once the table is loaded, I need to let the user select date ranges to filter the data since/before/between one/two dates. I'd like to have a couple of javascript calendars that will trigger the DataTable to refresh its data according to the dates selected.

I know how to do it with a page refresh: push values into aoData in the body of a function sent to parameter fnServerData when the table is defined... But I'd like to do it without refreshing the page each time.

I see fnDraw() will refresh the table, and I guess I could do some complex backend processing with fnFilter("2012-03-01/2012-03-31") but that's a hack I'd hate support long term. ;-)

How can I have the table send multiple values to the server to be processed after the table is initially loaded?

Replies

  • thunderrabbitthunderrabbit Posts: 7Questions: 0Answers: 0
    I hope this is better wording for my question:

    After the table is initially loaded, how can I ajax multiple values to the server and update the table based on the server response?
  • thunderrabbitthunderrabbit Posts: 7Questions: 0Answers: 0
    Ah, I found references to fnReloadAjax, so I just need to figure out where to download that plugin, and maybe put it into a separate file like tacman1123 http://www.datatables.net/forums/discussion/4262/fnreloadajax-in-separate-js-file/p1
  • thunderrabbitthunderrabbit Posts: 7Questions: 0Answers: 0
    Okay, I've read through fnReloadAjax definition (about 20 times) at http://www.datatables.net/plug-ins/api

    Lines 10, 12, and 14 seem to point toward the magic key I'm missing.

    [code]
    var aData = [];

    this.oApi._fnServerParams( oSettings, aData );

    oSettings.fnServerData( oSettings.sAjaxSource, aData, function(json) {
    [/code]

    Line 12 calls fnServerParams which will populate aData with its original values, right?

    So I think my question now is how to tell fnServerParams to return new values at runtime?
  • thunderrabbitthunderrabbit Posts: 7Questions: 0Answers: 0
    http://www.datatables.net/ref#fnServerParams says it modifies a reference to aoData. Can I modify aoData with something like this?

    [code]
    myTable.aoData.push(nameValueArray);
    [/code]
  • thunderrabbitthunderrabbit Posts: 7Questions: 0Answers: 0
    I think implementing something like this will solve it http://stackoverflow.com/questions/7629218/update-server-processed-datatables-source-with-additional-parameters
  • thunderrabbitthunderrabbit Posts: 7Questions: 0Answers: 0
    And it looks like this will allow access to set aoData programmatically: http://stackoverflow.com/a/7241842/194309
This discussion has been closed.