Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datatable custom error handling not working

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.

like image 345
pixelr Avatar asked May 17 '15 03:05

pixelr


1 Answers

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

  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.

  2. The correct option to target is $.fn.dataTable.ext.errMode.

  3. 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);
})
like image 165
davidkonrad Avatar answered Nov 15 '22 00:11

davidkonrad