How to get a filtered dataset of data from jQuery Datatable

It would be great if someone helped me in this matter.

I'm just trying to get a filtered result set from a datatable.

Below is my code.

var filtered_row_data = $('#example').DataTable().column(1).search('186').data().unique().sort(); console.log(JSON.stringify(filtered_row_data)); 

It simply returns all rows instead of the filtered values.

I am using the latest stable version of Datatable.

Can anyone help with this?

+6
source share
1 answer

see dataTables selector modifiers . You are looking for {filter : 'applied'} :

 table.on('search.dt', function() { //number of filtered rows console.log(table.rows( { filter : 'applied'} ).nodes().length); //filtered rows data as arrays console.log(table.rows( { filter : 'applied'} ).data()); }) 

demo β†’ http://jsfiddle.net/h4wrmfx3/

+25
source

All Articles