How can I trigger fnServerData from an "external" button?

How can I trigger fnServerData from an "external" button?

frequentfrequent Posts: 23Questions: 0Answers: 0
edited July 2012 in General
I have a table that displays two sets of data using server-side processing and AJAX-updating (done like this: http://www.mccran.co.uk/examples/datatable/index.cfm)

To switch between my two datasets, I have a select element, which I added to the table layout. I now want to trigger fnServerData when the user selects a different dataset from the select menu.

Question is: Can fnServerData be triggered from "external" buttons?

I tried calling with a custom event fired on select-change and listening inside the respective tables fnInitComplete like so:

[code]
$(window).on('repaint_orders', function(){
$('.tbl_orders').fnServerData( sSource, aoData, fnCallback, oSettings );
});
[/code]

But that doesn't work, as all of the required variables aren't defined.

Is there a direct way to trigger an update/submit of the table?

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    > Question is: Can fnServerData be triggered from "external" buttons?

    If you are using server-side processing like in the article you linked to - then yes. Just call the API method fnDraw which will redraw the table and thus call fnServerData.

    Allan
  • frequentfrequent Posts: 23Questions: 0Answers: 0
    Cool. I'll be trying that out! Thanks!
  • frequentfrequent Posts: 23Questions: 0Answers: 0
    Perfect. Works well. Thanks for the pointer!
This discussion has been closed.