我有一张id为teachertable的表。我正在使用数据表。代码如下。
this.teacherstable = jQuery('#teacherstable').DataTable({
"language": {
"emptyTable": "No records to display.",
},
responsive: true,
"pageLength": 10,
"bLengthChange": false,
"data": this.teachers,
"order": [[0, "desc"]],
"columns": [
{
"title": "Modified Date",
"mData": null,
"mRender": function (data, type, row) {
return row["ModifiedDate"];
},
"visible": false,
"bSortable": true,
},
{
"title": "Teacher Name",
"mData": null, "mRender": function (data, type, row) {
return row["FirstName"] + " " + row["LastName"];
}
},
{
"title": "Email",
"mData": null, "mRender": function (data, type, row) {
return row["Email"];
}
},
{
"title": "Mobile Number",
"mData": null, "mRender": function (data, type, row) {
return row["PhoneNumber"];
}
},
{
"title": "Date Of Birth",
"mData": null, "mRender": function (data, type, row) {
return row["DateofBirth"];
}
},
],
});
现在我的问题是我从服务器获取教师数据。基于收到的数据,我必须在属性pagination:false
的数据表中启用和禁用分页。这该怎么做。任何建议都会有很大帮助。
答案 0 :(得分:0)
您可以使用三元操作:
jQuery('#teacherstable').DataTable({
[...],
"paging": ( "your condition" ? true : false),
[...]});