jQuery Datatables-从其他页面检索信息 [英] jQuery Datatables - retrieving information from other pages

查看:72
本文介绍了jQuery Datatables-从其他页面检索信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从jQuery数据表获取信息时遇到问题. 这是表格:

I have got a problem with getting information from jQuery datatable. Here is the table:

我想获取存储在表中的信息.我已经尝试通过以下方式做到这一点:

I would like to get information stored in the table. I have tried to do this by this:

var languages=[];
var people=[];

$("select[name='languageID']").each(function(){
    languages.push( $(this).val() );
});

$("input:hidden[name='personID']").each(function(){
    people.push( $(this).val() );
});

,但是它正在从当前选择的页面获取值.如果在类似屏幕快照的情况下运行此命令,则只有第2页中的值会被推送到数组中.我试图检查页面1的值存储在哪里,但找不到任何东西.我也在 jQuery数据表首页

but it is getting values from current chosen page. If I run this in the situation like on the screenshot, only values from page 2 would be pushed to the arrays. I have tried to check where values from page 1 are stored, but I could not find anything. I also looked for it on jQuery datatables homepage

有人可以帮忙吗?

致谢

所以我应该做这样的事情:

so I should do something like this:

table.column( 0 ).cache( 'search' ).each( function ( d ) { /*action here*/ } ); 

?

但是应该采取什么行动?

But what should be in action?

当我调试table.column( 2 ).cache( 'search' );时,我已经得到了:

When I debug table.column( 2 ).cache( 'search' ); I have got this:

[   choose language ", " choose language ", " choose language ", " choose language ", " choose language ", " choose language " ]

这是选择语言"选择中的第一个选项.我认为,我需要一些东西,该东西将从列中的每个单元格返回html代码,以便以后进行分析.

It is first option in "Chosen language" select. I think, that I need something, which would return html code from each cell in column, so that I can analyse it later.

推荐答案

这个结果比预期的要难.首先,我尝试使用数据表 data() API,但这会返回下拉列表作为HTML字符串,不是很有用.然后,我遇到了文章关于数据表如何处理表单输入的内容.诀窍是要认识到,无论分页如何,数据表对象都可以从文档中检索节点.

This one turns out harder than expected. At first, I try using the datatable data() API, but that returns the dropdown lists as HTML strings, which are not very useful. Then I come across this article on how datatable deals with form inputs. The trick is to recognize that your datatable object can retrieve nodes from within the document regardless of paging.

可以在我的 jsfiddle 上找到实时演示.

A live demo can be found on my jsfiddle.

根据与OP的讨论,可以使用以下代码,而不是依赖于嵌入式列选择器:

As per discussion with OP, the following codes can be utilized instead of relying on embedded column selectors:

table.$('select[name="languageID"]').each(function(index, value{
    languages.push($(value).val());
});

这篇关于jQuery Datatables-从其他页面检索信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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