Best way to do deferred loading client-side?

Best way to do deferred loading client-side?

benjohnsonbenjohnson Posts: 1Questions: 0Answers: 0
edited July 2013 in General
Hello!

I've got a bit of an odd situation. I need to load initial few pages by setting aaData (or otherwise get data from a JS object into DataTables for the initial load). Then, when someone interacts with filtering, sorting, or pagination, I'd like to do a call to the server to get the rest of the data (which could be a lot) and then lean on clientside filtering and sorting. It's a highly trafficked page, and so I'd like to defer dealing with all the data unless I need it. For a variety of reasons, I can't do server-side processing.

I know iDeferLoading only works server-side. I was thinking I would just load the initial data with aaData and then use the add function to add a bunch of rows. Here's a few questions:

1) I'm not seeing events related to filtering, sorting, pagination. Is there a way for me to tell if people are interacting with stuff?
2) I'm not seeing a way to fire the processing message. I can MacGyver my own, but it would be nice if I could just turn it on while I make my own call, since it would disable other interaction with DataTables.
3) Is there a better way to do this than to directly add rows? Can DataTables defer doing things?

Thanks for the assistance!

Ben.

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    > 1) I'm not seeing events related to filtering, sorting, pagination. Is there a way for me to tell if people are interacting with stuff?

    There are events for these actions: http://datatables.net/docs/DataTables/1.9.4/DataTable.html#summary_events

    > 2) I'm not seeing a way to fire the processing message

    This plug-in presents a public API for it: http://datatables.net/plug-ins/api#fnProcessingIndicator

    > 3) Is there a better way to do this than to directly add rows?

    Currently, I think this probably is the best way - wait for user interaction and then load the full data set and add them to the table (make sure bDeferRender is enabled). Building it into DataTables is something I want to do - more specifically extend iDeferLoading to Ajax, but when I looked at it before, it wasn't going to be trivial - so its on hold until I can finish off 1.10 and come back to it.

    Allan
This discussion has been closed.