Acquiring column data after column is hidden
Acquiring column data after column is hidden
http://live.datatables.net/tawilawu/2/edit
In the above link I have an example where we are able to toggle the visibility of columns.
In my real-time application, the Datatables is server-side paginated. We may have millions of records, but we are slicing up the data when presenting in browser. We have a requirement to be able to export several thousands of rows into a CSV file based on certain search criterias on columns. For example, export records of all employees in London office.
Because server-side pagination is not bringing in the whole records in browser, I am forming the CSV on server and not using Datatables export options. However, I do need to submit values that were typed in the column search fields to the server. I can obtain the search values when the column is visible. But in case the column was invisible, I have not been able to find the <input> element in the header for that column and thus its value is undefined.
My question is: How can I find the <input> element of the column that was hidden? There are two JQuery cases that I am using to find the input element in the example link:
- $("#search-"+this.name()).val() which returns undefined if column is hidden
- $('#example thead tr:eq(1) th:eq(2)').each(function(index, value){
console.log(value.innerHTML);
});
which returns the Age column when Office is hidden.
Thank you.
This question has an accepted answers - jump to answer
Answers
The easiest way would be to use
column().search()
, this returns the string that was used to search that column last.Colin