【发布时间】:2018-04-26 02:57:41
【问题描述】:
在我的 DataTable 上,您可以选择每页要显示多少项目的框不起作用。它向我展示了这个:
[[5,10],[5,10]] 只显示数字。
我试图了解导致此问题的原因,但没有成功。
如果我单击菜单选项之一,我也会遇到此错误:Showing NaN to NaN of 2 entries
我在我的 Rails 4 应用程序中使用它。
这是我的 js:
var dtMainDataTable; // Reference to main table
var dtSecondaryDataTable; // Reference to secondary table
var dtTertiaryDataTable; // Reference to tertiary table
var dtMainOrder; // Main table ordering
/*
* Create tables on document ready
*/
$(document).ready( function() {
// Set the order of the main table and update if overridden by page.
dtMainOrder = [0, 'asc'];
if (typeof dtMainOrderUpdate !== 'undefined') {
dtMainOrder = dtMainOrderUpdate;
}
dtMainDataTable = $('#main').DataTable({
columnDefs: [],
"pageLength": pageLength,
"lengthMenu": pageSettings,
"order": dtMainOrder,
responsive: true
});
dtSecondaryDataTable = $('#secondary').DataTable({
columnDefs: [],
"pageLength": pageLength,
"lengthMenu": pageSettings,
responsive: true
});
dtTertiaryDataTable = $('#tertiary').DataTable({
columnDefs: [],
"pageLength": pageLength,
"lengthMenu": pageSettings,
responsive: true
});
});
/**
* Show all items in the main table.
* Really only for testing purposes.
*
* @return [Null]
*/
function dtMainTableAll() {
dtMainDataTable.page.len(-1).draw();
}
【问题讨论】:
-
你需要使用 paginate:true 和 paginatetype : full_numbers 属性
-
我必须在我使用表格的视图中包含那些? @sridharreddy
-
我添加了那些我仍然有同样问题的人
标签: javascript jquery ruby-on-rails datatables