我在我的表中使用数据表,我在ajax调用中调用数据表函数,如
function readbroadcastedmessagelist()
{
var usertype = $("#user-type :selected").text();
$.ajax({
url: 'index.php?action=fetchBroadcastedMessageList',
type: 'POST',
dataType: 'JSON',
data: { usertype: usertype },
success: function (data) {
$('.filter-table').css("display","block");
$('#broadcastedmessagelist').empty();
// console.log(data);
if (data.length)
{
$('#broadcasttable table').dataTable({
"sPaginationType": "full_numbers"
});
for (var i in data) {
$("#broadcastedmessagelist").append('<tr>' +
'<td style="text-align: center; text-transform:capitalize">' +
'' + (data[i].userdetails.length ? data[i].userdetails[0]["role"] : ' - ') +
'' + '</td>' + '<td style="text-align: center;">' + '' +
dateSentTextValue + '' + '</td>' +
'<td style="text-align: center;" class="footable-visible">' +
'<span class="label'+ ' '+ className + '">' + '' + TextValue +
'' + '</td>' + '<td style="text-align: center;">' +
'<button data-id=' + '"' + data[i]['broadcast_id'] + '"' +
'class="modalLink btn btn-primary btn-xs" type="button"' +
data-toggle="modal" data-target=".myModal">' +
'<span class="bold"><i class="fa fa-eye"></i> View</span></button>' +
'</td>' +
'</tr>');
}
}
},
error: function (request, status, error) { }
});
}
我正在尝试调整数据表代码,以便仅实现分页功能,以便省略其余功能。
首先显示“表格中没有数据”,然后在表格中显示其余数据。
分页无法正常工作。表格中未添加页码。
应该有显示每页显示记录的下拉列表的选项。
- 醇>
尽管表格中有数据,但仍显示“显示0条目0到0”。
html标记为
<table class="table table-striped table-bordered table-hover dataTable no-footer" id="DataTables_Table_0" role="grid" aria-describedby="DataTables_Table_0_info">
<thead>
<tr role="row"><th style="text-align: center; width: 0px;" rowspan="1" colspan="1">
Sender
</th><th style="text-align: center; width: 0px;" rowspan="1" colspan="1">
Sending Date
</th><th style="text-align: center; width: 0px;" rowspan="1" colspan="1">
Status
</th><th style="text-align: center; width: 0px;" rowspan="1" colspan="1">
View
</th></tr>
</thead>
<tbody id="broadcastedmessagelist"><tr><td style="text-align: center; text-transform:capitalize">admin</td><td style="text-align: center;">07/04/2017</td><td style="text-align: center;" class="footable-visible"><span class="label label-danger">Not Delivered</span></td><td style="text-align: center;"><button data-id="77" class="modalLink btn btn-primary btn-xs" type="button" data-toggle="modal" data-target=".myModal"><span class="bold"><i class="fa fa-eye"></i> View</span></button></td></tr>
<tr><td style="text-align: center; text-transform:capitalize">admin</td><td style="text-align: center;">07/04/2017</td><td style="text-align: center;" class="footable-visible"><span class="label label-danger">Not Delivered</span></td><td style="text-align: center;"><button data-id="80" class="modalLink btn btn-primary btn-xs" type="button" data-toggle="modal" data-target=".myModal"><span class="bold"><i class="fa fa-eye"></i> View</span></button></td></tr>
<tr><td style="text-align: center; text-transform:capitalize">admin</td><td style="text-align: center;">17/04/2017</td><td style="text-align: center;" class="footable-visible"><span class="label label-danger">Not Delivered</span></td><td style="text-align: center;"><button data-id="81" class="modalLink btn btn-primary btn-xs" type="button" data-toggle="modal" data-target=".myModal"><span class="bold"><i class="fa fa-eye"></i> View</span></button></td></tr>
<tr><td style="text-align: center; text-transform:capitalize">admin</td><td style="text-align: center;">17/04/2017</td><td style="text-align: center;" class="footable-visible"><span class="label label-danger">Not Delivered</span></td><td style="text-align: center;"><button data-id="82" class="modalLink btn btn-primary btn-xs" type="button" data-toggle="modal" data-target=".myModal"><span class="bold"><i class="fa fa-eye"></i> View</span></button></td></tr><tr><td style="text-align: center; text-transform:capitalize">admin</td><td style="text-align: center;">17/04/2017</td><td style="text-align: center;" class="footable-visible"><span class="label label-danger">Not Delivered</span></td><td style="text-align: center;"><button data-id="83" class="modalLink btn btn-primary btn-xs" type="button" data-toggle="modal" data-target=".myModal"><span class="bold"><i class="fa fa-eye"></i> View</span></button></td></tr>
<tr><td style="text-align: center; text-transform:capitalize">admin</td><td style="text-align: center;">17/04/2017</td><td style="text-align: center;" class="footable-visible"><span class="label label-danger">Not Delivered</span></td><td style="text-align: center;"><button data-id="84" class="modalLink btn btn-primary btn-xs" type="button" data-toggle="modal" data-target=".myModal"><span class="bold"><i class="fa fa-eye"></i> View</span></button></td></tr><tr><td style="text-align: center; text-transform:capitalize">admin</td><td style="text-align: center;">17/04/2017</td><td style="text-align: center;" class="footable-visible"><span class="label label-danger">Not Delivered</span></td><td style="text-align: center;"><button data-id="85" class="modalLink btn btn-primary btn-xs" type="button" data-toggle="modal" data-target=".myModal"><span class="bold"><i class="fa fa-eye"></i> View</span></button></td></tr><tr><td style="text-align: center; text-transform:capitalize">admin</td><td style="text-align: center;">17/04/2017</td><td style="text-align: center;" class="footable-visible"><span class="label label-danger">Not Delivered</span></td><td style="text-align: center;"><button data-id="86" class="modalLink btn btn-primary btn-xs" type="button" data-toggle="modal" data-target=".myModal"><span class="bold"><i class="fa fa-eye"></i> View</span></button></td></tr><tr><td style="text-align: center; text-transform:capitalize">admin</td><td style="text-align: center;">17/04/2017</td><td style="text-align: center;" class="footable-visible"><span class="label label-danger">Not Delivered</span></td><td style="text-align: center;"><button data-id="87" class="modalLink btn btn-primary btn-xs" type="button" data-toggle="modal" data-target=".myModal"><span class="bold"><i class="fa fa-eye"></i> View</span></button></td></tr><tr><td style="text-align: center; text-transform:capitalize">admin</td><td style="text-align: center;">17/04/2017</td><td style="text-align: center;" class="footable-visible"><span class="label label-danger">Not Delivered</span></td><td style="text-align: center;"><button data-id="88" class="modalLink btn btn-primary btn-xs" type="button" data-toggle="modal" data-target=".myModal"><span class="bold"><i class="fa fa-eye"></i> View</span></button></td></tr></tbody>
</table>
请帮帮我!!!