jneuhaus
jneuhaus

Reputation: 11

How to collect all the id values for a yadcf filtered table

I'm using datatables and yadcf to filter a table. Now I'd like to take all the table row id values, for example, and use those as arguments in a POST request. How can I "collect" the values of these ids from the result of the filters that have been applied? I've seen this example, which doesn't seem to apply to yadcf, but is similar to my use-case.

Upvotes: 0

Views: 189

Answers (2)

pierrelesek
pierrelesek

Reputation: 1

Yes, the submit content is only the visible row with datatables.

If you have 5 rows and after filter 2 rows, if you click on submit button with the active filter only 2 rows will be submitted.

And if, conversely, you still wanted to submit all the elements of the table despite the filtering, on the onsubmit there is a yadcf function that you just have to execute which deactivates all active filtering to submit the entire table like this :

var table = $('#mytable').DataTable( {}) ;
document.onsubmit = function(){ 
    yadcf.exResetAllFilters(table) ;  
};

Upvotes: 0

jneuhaus
jneuhaus

Reputation: 11

I was able to get the information I wanted using the answer found here. I didn't realize that jQuery will select only the visible elements, which is what I want. So, after applying the yadcf filter to my table it's simple to select all the tr.id values resulting from the filter.

Upvotes: 0

Related Questions