如何从 jQuery Datatable 中获取过滤后的数据结果集 [英] How to get filtered Data result set from jQuery Datatable
本文介绍了如何从 jQuery Datatable 中获取过滤后的数据结果集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果有人在这个问题上帮助我,那就太好了.
It would be great if someone help me on the issue.
我只是想从数据表中获取过滤后的结果集.
I am just trying to get the filtered result set from the Datatable.
下面是我的代码.
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.
我使用的是最新的稳定版 Datatable.
I am using latest stable version of Datatable.
有人可以帮忙吗?
推荐答案
查看数据表 selector-modifiers.您正在寻找 {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());
})
演示 -> http://jsfiddle.net/h4wrmfx3/
demo -> http://jsfiddle.net/h4wrmfx3/
这篇关于如何从 jQuery Datatable 中获取过滤后的数据结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文