Getting access to filter text and which columns are sorted

Getting access to filter text and which columns are sorted

bramseybramsey Posts: 3Questions: 0Answers: 0
edited January 2010 in General
I have created a routine in our MVC applcation that exports data into an Excel file based on what is in the grid. The catch is that we are exporting more data than is showing in the grid. Our grid has 7 columns. Our Excel file has about 15. There just isn't room to display all of them on the screen.

A link is clicked in order for the export to take place. Basically we are rerunning the original query that loaded the grid when the link is clicked. This means that any sorting or filtering is ignored. Is there a way to grab what has been entered in the filter text box and also grab the columns that have been sorted on? This would allow us to use that information in our query when creating the Excel file. Hopefully this makes sense. Any help is appreciated. Thank you.

Replies

  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin
    Hi bramsey,

    Yes indeed - you can get this information from the DataTables settings object ( http://datatables.net/api#fnSettings ). These settings are internal, so not documented (have a peak at the code), but what you are looking for is: oPreviousSearch.sSearch and aaSorting.

    Regards,
    Allan
  • bramseybramsey Posts: 3Questions: 0Answers: 0
    Thanks Allan. The sSearch gives us everything we need. I appreciate the reply.
  • bramseybramsey Posts: 3Questions: 0Answers: 0
    We also found that oSettings.asDataSearch returns the data in a sorted and filtered state.
This discussion has been closed.