【问题标题】:How to show custom message in datatable?如何在数据表中显示自定义消息?
【发布时间】:2018-12-05 06:53:00
【问题描述】:

我有dataTable,我需要在没有数据时显示自定义错误消息。 如果成功消息添加的记录不绑定。 当数据表“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' },

【问题讨论】:

标签: jquery datatable


【解决方案1】:

取自DataTable docs,添加此代码:

table = $("#operator-datatable").DataTable({
    "language": {
        "zeroRecords": "Custom error message goes here"
    }
    //Rest of your code
})

【讨论】:

    猜你喜欢
    • 2012-07-05
    • 1970-01-01
    • 1970-01-01
    • 2021-07-16
    • 2011-09-21
    • 1970-01-01
    • 1970-01-01
    • 2012-12-31
    相关资源
    最近更新 更多