Ajax and custom parameters - howto/best practice?

Ajax and custom parameters - howto/best practice?

mahlermahler Posts: 6Questions: 0Answers: 0
edited August 2009 in General
I've been rewriting a user management backend for a CMS system. The system has a very large number of users, and in the pre-Datatables version we've had an option to filter by "groups" and the account state.

In past uses of Datatables with a similar use-case I've reloaded the page, but I'd really like set pass the value to the Ajax Call and reload/redraw the table with fresh data.

In the Datatables version I'm using an Ajax-backed for all table data, and I would like to be able to pass parameters along with the Ajax-calls when they're set.

Is it possible?

Replies

  • mahlermahler Posts: 6Questions: 0Answers: 0
    The code is quite similar to the example here:
    http://datatables.net/1.5-beta/examples/data_sources/server_side.html

    In this case, I'd like to be able to pass a value (through) to the ajax call to restrict the results to only include Windows browsers.
  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin
    Hi mahler,

    You can add custom variables to the get request as shown in this demo: http://datatables.net/1.5-beta/examples/server_side/custom_vars.html

    Regards,
    Allan
  • mahlermahler Posts: 6Questions: 0Answers: 0
    Thank, it was just the example I needed :)

    Tips for others with a similar need...

    I added the "fnServerData" from the custom_vars example, and changed the array passed ind the aoData.push to contain the selected values from the two drop-downs. That was fine, but the table also needed to reload the data once the values for the dropdowns changed.

    To fix this I had to add the fnReloadAjax plugin available here http://datatables.net/plug-ins#extras - and attached to the change-event on the two dropdowns with state and group, but once that was in place, everything works just fine.
  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin
    Hi mahler,

    Nice one - thanks for the update and advice for others. I'm sure it will be useful!

    Regards,
    Allan
This discussion has been closed.