我正在使用数据表并通过ajax加载数据。该表永远不会有很多行,因此不需要分页,搜索和排序。除了分页控件和信息(显示2个条目中的1到2个)仍然可见之外,下面的代码工作正常。我试图在表的初始化中添加“bPaginate”:false但它从不显示数据。它只是说“处理”......
<script type="text/javascript">
$(document).ready(function () {
var dataTable = $('#dataTablecontacts').dataTable({
"bServerSide": true,
"sAjaxSource": "/Contact/GetDataTable/@Model.Id",
"bProcessing": true,
"bFilter": false,
"bSort": false,
"bLengthChange": false,
"aaSorting": [[1, "asc"]],
"aoColumns": [
{ "mData": "Id", "bSearchable": false, "bSortable": false, bVisible: false },
{ "mData": "Name" },
{ "mData": "Position" },
{ "mData": "OfficePhone", "bSearchable": false, "bSortable": false },
{ "mData": "MobilePhone", "bSearchable": false, "bSortable": false },
{ "mData": "Email", "bSearchable": false, "bSortable": false },
{ "mData": "BusinessPartner", "bSearchable": false, "bSortable": false, bVisible: false },
]
});
$("#dataTablecontacts tbody").on("click", "tr", function (event) {
var id = dataTable.fnGetData(this)['Id'];
var viewUrl = "/Contact/Details/" + id;
window.location = viewUrl;
});
});
答案 0 :(得分:0)
如果您只想隐藏它们,请添加此项:
$('.dataTables_paginate, .dataTables_filter').css({display: 'none'});