jquery - 如何在数据表中显示自定义消息?
问题描述
我有数据表,我需要在没有数据时显示自定义错误消息。如果成功消息添加的记录不绑定。当数据表“zeroRecords”:“”时,应显示自定义消息,不影响实际功能
table = $('#operator-datatable').DataTable({
processing: true,
serverSide: true,
searching: false,
stateSave: boolstatus,
ajax: {
url: _API.apiBaseUrl + 'OperatorManage/Operator/List',
type: 'POST',
headers: _API.headers,
"dataSrc":"tableData",
data: function (d) {
d.columns[0].search.value = $('#bankernumber').val();
d.columns[6].search.value = $('#branchnumber').val();
d.columns[4].search.value = $('#revokestatus').val();
d.columns[2].search.value = $('#operatorjurisdictiontype').val();
},
success: function (res) {
$('.dataTables_processing').hide();
//var response = JSON.parse(res);
console.log(res);
alert("hi");
},
error: function (xhr, textStatus, errorThrown) {
_API.alertAjaxError(xhr);
$('.dataTables_processing').hide();
},
},
columns: [
{ data: 'bankernumber' },
{ data: 'bankername' },
{ data: 'jurisdictiontype' },
解决方案
Taken from the DataTable docs, add this code:
table = $("#operator-datatable").DataTable({
"language": {
"zeroRecords": "Custom error message goes here"
}
//Rest of your code
})
推荐阅读
- reactjs - 将路由器与其他查询参数反应相同的路径
- python-3.x - 将 3d 列表转换为同一索引上的 pandas 单个数据帧
- apache-kafka - Kafka 源连接作业使用更新的配置重新启动,但任务仍使用旧配置
- python - 如何检查 csv 文件的一列并将另一列中的数据添加到列表中?
- google-sheets - 从最后一个斜杠中删除部分网址(Google 表格)
- django - 我怎样才能在传单中获得我的真实地理位置
- php - php:将字符串拆分为关联数组的更好方法
- javascript - VUE JS在安装后将对象传递给孩子
- javascript - for循环中的onclick多个事件
- c - 如何让每个 scanf 工作而不跳过