Pre process the data while using the server method

Pre process the data while using the server method

orenoren Posts: 3Questions: 0Answers: 0
edited June 2012 in DataTables 1.9
Hi,
Is there a way to get the data from the server as RAW json and process it on the client side before dataTables uses it?

By processing i mean - adding the extra nessesary data like sEcho,DT_RowId,DT_RowClass and avoiding extra looping in the server side in order to add this data to the db recordset.

Thanks

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited June 2012
    Sure - you can use fnServerData or listen for the 'xhr' event. fnServerData means you need to define your own $.ajax call (a couple of lines of jQuery), while with the xhr event you don't - you bind to the table instance and listen for that event, and which caught the jqXHR object is available in fnSettings().jqXHR and thus can be manipulated as needed.

    fnServerData is easier to get started with :-).

    > sEcho

    This suggests that you are going to be using server-side processing. If that is the case you will need to know the number of records in the record set both filtered and unfilled. Does your JSON return give you that information. Also sEcho is important due to the asynchronous nature of Ajax to ensure that overlapping responses are processed in the correct order - which might be a little challenge without that information!

    > adding the extra nessesary data like sEcho,DT_RowId,DT_RowClass

    I should also say that non of these parameters are required (sEcho is if using server-side processing, but not for client-side).

    Allan
  • orenoren Posts: 3Questions: 0Answers: 0
    Thank you.
    BTW, this is the best third party component i ever worked with.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Thank you too :-)

    Allan
This discussion has been closed.