数据表自定义错误处理不起作用 [英] Datatable custom error handling not working

查看:77
本文介绍了数据表自定义错误处理不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用数据表插件编写应用程序.我想处理插件通过函数抛出的错误,但是插件始终显示带有错误消息的警报框.

I am writing an application using Data-table plugin. I want to handle the error thrown by plugin by my function but plugin always show a alert box with error message.

在页面加载事件中,我正在创建一个数据表插件并注册一个处理程序.

In the page load event, I am creating a datatable plugin and registering a handler.

function callOnLoad()
{
    $.fn.dataTable.ext.errorMode = "none";

    auditViewTable = $("#div").on("error.dt",function(e, settings, techNote, message ){
        console.log("error");
    })
    .DataTable({
        "processing": true,
        "serverSide": true,
        "ajax": "getData",
        "columns": [
            { "data": "events" },
            { "data": "id" },
            { "data": "name" },
            { "data": "obj_id" },
            { "data": "obj" }
        ]
    });
}

请帮助我哪里出问题了.

Please help me where I am going wrong.

推荐答案

请参阅文档-> http://datatables .net/reference/event/error

See the documentation -> http://datatables.net/reference/event/error

  1. error.dt最早是在 1.10.5 中引入的!因此,您必须至少使用1.10.5.概念证明: 无效,1.10.4示例 /

  1. error.dt was first introduced in 1.10.5 !! So you must use at least 1.10.5. Proof of concept : works not, 1.10.4 example / works, 1.10.5 example.

正确的定位选项是$.fn.dataTable.ext.errMode.

一个工作示例将使用> 1.10.4和

A working example would be using >1.10.4 and

$.fn.dataTable.ext.errMode = 'none';
$('#example').on('error.dt', function(e, settings, techNote, message) {
   console.log( 'An error has been reported by DataTables: ', message);
})

这篇关于数据表自定义错误处理不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆