My DataTable has filtered and sorted data - how do I send that to the server?

My DataTable has filtered and sorted data - how do I send that to the server?

SarahCSarahC Posts: 1Questions: 1Answers: 0

I know that server sided filtering and sorting is supported by DataTable, but I'm in the position where the existing code sends the data set to the client in a repeater, and the client then does client sided filtering, sorting, and column order changing.

The server has some .Net plugins to process data, so I'd like to send what the user has filtered back to the server, and have the server create some fancy charts/grids/analysis.

I was hoping for something like:

dataTable.AJAXSendVisiblePage("serverProcessing.aspx");
//or
dataTable.AJAXSendFilteredSortedData("serverProcessing.aspx");

Failing this - how can I get the sorted and filtered data out of the DataTable object, so I can construct an AJAX JSON request myself?

Answers

  • allanallan Posts: 63,482Questions: 1Answers: 10,467 Site admin

    The selector-modifier option which can be passed into the various selector methods can be used. E.g.:

    table
      .rows( { search: 'applied', order: 'applied' } )
      .data()
      .toArray();
    

    will give a plain array of the data in the current order and with only the currently filtered rows.

    Allan

This discussion has been closed.