如何从jQuery Datatable中获取过滤后的数据结果集 [英] How to get filtered Data result set from jQuery Datatable

查看:860
本文介绍了如何从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.

我正在使用最新的稳定版本的数据表.

I am using latest stable version of Datatable.

有人可以帮忙吗?

推荐答案

请参阅dataTables 选择器修饰符 > .您正在寻找{filter : 'applied'}:

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());                                  
})  

演示-> http://jsfiddle.net/h4wrmfx3/

demo -> http://jsfiddle.net/h4wrmfx3/

这篇关于如何从jQuery Datatable中获取过滤后的数据结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆