2011-07-07 43 views
0

我在网站上看过,但我找不到如何将sInfo放入jQuery数据表插件的表格脚注中。我查看了他们的文档,但没有看到任何东西。有任何想法吗?Datatables插件

编辑帖子:

$(document).ready(function() { 

$('#usersPageList').dataTable({ 
    "sDom": 'rt<"pagination"p>', 
    "iDisplayLength": 1, 
    "sPaginationType": "full_numbers", 
}); 

var info = $('.dataTables_info') 
var clone = info.clone(); 
info.hide(); 
$('tfoot').append(clone); 

}); 

编辑后2:

Pastebin Code

+1

意识到'sinfo',因为我可以帮忙。 –

+0

我正在寻找的主要部分是显示x行总数x或其他。 –

回答

1

其实你需要玩一点sDom选项。从文档采取:

This initialisation variable allows you to specify exactly where in the DOM you want DataTables to inject the various controls it adds to the page (for example you might want the pagination controls at the top of the table). DIV elements (with or without a custom class) can also be added to aid styling. The follow syntax is used: 
The following options are allowed: 

'l' - Length changing 
'f' - Filtering input 
't' - The table! 
'i' - Information 
'p' - Pagination 
'r' - pRocessing 
The following constants are allowed: 
'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix') 
'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix') 
The following syntax is expected: 
'<' and '>' - div elements 
'<"class" and '>' - div with a class 
'<"#id" and '>' - div with an ID 
Examples: 
'<"wrapper"flipt>', '<lf<t>ip>' 

所以例如如果这样做(我想你正在使用jquery UI <“H” LFR>吨<“F” IP>你有长度改变,所述过滤器和所述“正在处理...“(如果你已经启用了ajax),你有了这个表格,那么你就可以在页脚中获得信息和分页信息了,如果你希望你可以多次使用这些字母,那么你可以把信息两次或三次,如果你想

编辑 - 在您的评论你说你要添加表格的TFOOT在这种情况下,你可以只手动添加:。

$(document).ready(function() { 

$('#usersPageList').dataTable({ 
    "sDom": 'rti<"pagination"p>',//add i here this is the number of records 
    "iDisplayLength": 1, 
    "sPaginationType": "full_numbers", 
}); 

var info = $('.dataTables_info') 
$('tfoot').append(info); 

}); 
+0

但我正在谈论桌脚,不知道那会是怎样的。 –

+0

我编辑了我的答案,将数据插入到tfoot中 –

+0

我更新了上面的帖子,向您展示了我不知道当前问题的jQuery代码。 –

1

您正在寻找的bInfo option

启用或禁用信息显示表 信息显示。这显示 有关当前在页面上显示的 的数据信息, 包括有关过滤的 数据(如果执行的操作是 )的信息。

+0

对不起,我以为我把它看作sInfo。但是,如何将其显示在表格页脚而不是页脚 –

+1

@Jeff:它看起来像信息显示在表格下方,但实际上并不在'tfoot'元素中。那是你想要的地方吗? –

+0

我想很好地在tfoot中很好地显示它,如果可能的话。 –