如何从 jQuery Datatable 中获取过滤后的数据结果集
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33169649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get filtered Data result set from jQuery Datatable
提问by Raja
It would be great if someone help me on the issue.
如果有人在这个问题上帮助我,那就太好了。
I am just trying to get the filtered result set from the 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 just returns all the rows instead of filtered values.
它只返回所有行而不是过滤值。
I am using latest stable version of Datatable.
我正在使用 Datatable 的最新稳定版本。
Can anyone please help on this?
任何人都可以帮忙吗?
回答by davidkonrad
see dataTables selector-modifiers. You are looking for {filter : 'applied'}
:
请参阅数据表选择器修饰符。您正在寻找{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/