How can I show blockui/loader predraw?

How can I show blockui/loader predraw?

dtoct6dtoct6 Posts: 4Questions: 2Answers: 0

I have the following setup: https://live.datatables.net/cakipivi/1/

I cannot figure out how I can get the blockUI to appear predraw, or upon click of the searchpane. I want to show the loading screen while it is processing the redraw. Is there a way to do that?

Answers

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin

    Why specifically on the SearchPane click? I'd have thought you'd be better just listening for processing and enabling or disabling the UI block based on that? Then it doesn't matter how the processing of the main table is triggered, it will work for all. Also, using a setTimeout of 50mS doesn't seem right to me - you probably want to leave the blocker under the table is redrawn, which is another reason to use the processing event.

    Allan

  • dtoct6dtoct6 Posts: 4Questions: 2Answers: 0

    I have tried the processing event however it redraws too many times for the UI block to be displayed.

    https://live.datatables.net/gaxepude/2

  • dtoct6dtoct6 Posts: 4Questions: 2Answers: 0

    With this code,

    .on("processing.dt", function(e, settings, processing) {
        if (processing) {
          console.log('processing');
            $.blockUI({
                message: "Loading"
           });
        } else {
          console.log('done');
            $.unblockUI();
        }
    });
    

    Results in

    "processing"
    "done"
    "processing"
    "done"
    "processing"
    "done"
    "processing"
    "done"
    "processing"
    "done"
    "processing"
    "done"
    "processing"
    "done"
    "processing"
    "done"
    "processing"
    "done"
    "processing"
    "done"
    "processing"
    "done"
    

    However, when a selection is made in the search pane, nothing is captured by processing event

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin

    It looks like processing: true isn't being triggered for some reason: https://live.datatables.net/cecayesu/1/edit . I'll look into that.

    Going back to your example, I think part of the issue is that Javascript is single threaded and the click handler in SearchPanes is synchronous. There isn't a way to change that at the moment without modifying SearchPanes. What you really want is the click to show the blocker, then use setImmediate to allow the browser to redraw the blocker, then go on to do the filtering needed.

    Sorry I don't have a better answer at the moment.

    Allan

Sign In or Register to comment.