Clear [loadingRecords] message when exception happen

Clear [loadingRecords] message when exception happen

AlexanderLamasAlexanderLamas Posts: 48Questions: 1Answers: 0

Hi everyone,

Currently I'm customizing the error message that pops up when some exception happen in the errorMode extension as code below:

$.fn.dataTable.ext.errMode = function (settings, helpPage, message) {
    Message.failMessage("My customized error message...");
};

But there is one thing I also would like to customize.
When loading data and an exception happen, the dataTable will show whatever is been set here

language: {
     loadingRecords: "Please wait - loading..."
}

and the dataTable keeps showing this message even after clicking on the popup.

My question is, how can I clean this message or give another message when an exception happen?

is there such a property like

language: {
     loadingRecordsError: "Sorry! Error loading data."
}

Thank you very much in advance guys!

Regards,
Alex

Replies

  • colincolin Posts: 8,085Questions: 0Answers: 1,357

    The example in the processing page may help - it's showing something similar.

    Colin

  • AlexanderLamasAlexanderLamas Posts: 48Questions: 1Answers: 0

    Hi Colin,

    Thanks for your reply.
    Actually the little popup processing is been hidden.
    The problem is that after the processing indicator (popup) disappears, I still get this code

    <tbody>
    <tr class="odd">
    <td valign="top" colspan="4" class="dataTables_empty">Loading, please wait...</td>
    </tr>
    </tbody>
    

    That is the message I'm trying to get rid off or perhaps replace it with a customized message if possible.

    So, is it possible to replace the "Loading, please wait..." in case I get an error when dataTable is loading?

    Thank you!

    Regards,
    Alex

  • colincolin Posts: 8,085Questions: 0Answers: 1,357

    "Loading, please wait..." isn't one of our messages, so it must've been customised already. You've probably got an option for language.processing,

    Colin

  • colincolin Posts: 8,085Questions: 0Answers: 1,357

    Sorry, meant to add, you can't modify it once set, but you can just change the text in hte DOM for that element if you detect an error.

  • AlexanderLamasAlexanderLamas Posts: 48Questions: 1Answers: 0

    Hi @colin ,

    Thanks for your reply.
    I end up solving the problem with code as follow:

    }).on('error.dt', function (e, settings, techNote, message) {
        const row = table.rows('.dataTables_empty');
        table.row(row).remove().draw(false);
    });
    

    Thank you very much for your help.
    Let me know if you see any danger on this approach.

    Thank you!

    Regards,
    Alex

Sign In or Register to comment.