Datatables插件

时间:2011-07-07 03:11:57

标签: jquery datatables

我查看了网站,但我无法找到如何将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

2 个答案:

答案 0 :(得分:1)

您在寻找bInfo option吗?

  

启用或禁用该表   信息显示。由此可见   有关数据的信息   目前在页面上可见,   包括有关过滤的信息   数据,如果该行动正在进行   进行。

答案 1 :(得分: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&lt;“H”lfr&gt; t&lt;“F”ip&gt;你有长度变化,过滤器和“处理...”(如果你在标题中你有ajax),你有表格,然后你在页脚中有信息和分页。如果你想要你可以多次使用这些字母,所以你可以把信息放两次或三次,如果你想。 / p>

编辑 - 在您的评论中,您说要添加表格的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);  

});