2011-07-07 78 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中很好地顯示它,如果可能的話。 –