Is there a way to hide the empty table message only when processing is true.

Is there a way to hide the empty table message only when processing is true.

ikhvjsikhvjs Posts: 9Questions: 3Answers: 0
edited December 2021 in DataTables

I try to use processing plugin to show the processing bar in the table, but I don't want to show theLanguage.emptyTable message (e.g. No data in the Table) if the processing is true.

Also, I want to show the emptyTable message when there is no record and the processing is false.

What I am trying to do in Javascript:

    async function render() {
        dataTable.processing(true);
        await asyncFetchData();
        dataTable.processing(false);
    }

May you give me some advice?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    I'm not seeing that - please see here. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Cheers,

    Colin

  • ikhvjsikhvjs Posts: 9Questions: 3Answers: 0
    edited December 2021

    Hi Colin,
    Thanks for your reply. You can see that No data available in the table is shown in your example when the processing is true. What I want is when processing is true, the No data available in the table should not be shown. When processing is false, the No data available in the table should be shown instead.

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Oh I see! You could blank out that message, something like this,

    Colin

  • ikhvjsikhvjs Posts: 9Questions: 3Answers: 0

    Thanks. I see. It looks like there is no api but manual js to handle it.

    Do you think there is a way to change the processing registration function below to add the toggling display of the emptyTable word?
    So, whiIe I write table.processing(true), it should hide the emptyTable text and when I write table.processing(false), it should show the emptyTable text if there is no record.

    I don't want to write $('.dataTables_empty').text(' ') and $('.dataTables_empty').text('No data available in the table') again for each operation in the code.

    jQuery.fn.dataTable.Api.register("processing()", function (show) {
        return this.iterator("table", function (ctx) {
                ctx.oApi._fnProcessingDisplay(ctx, show);
            });
        });
    }
    
  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    Answer ✓

    We'd be happy to accept a pull request for that change, it may be useful for others too,

    Colin

Sign In or Register to comment.