Processing indicator with stateRestore

Processing indicator with stateRestore

trongarttrongart Posts: 222Questions: 51Answers: 0

It it possible to show the processing indicator when a state is loaded from stateRestore?

I added processing : true and table.processing(true); with setTimeout into stateLoadParams, but this does not seem to work. Is there a different place where I need to add the processing code?

Test case: live.datatables.net/pivofaco/1/edit

Answers

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

    processing() is a plugin, so you'll need to include that in your code, something like this: http://live.datatables.net/bezonefo/1/edit

    Colin

  • trongarttrongart Posts: 222Questions: 51Answers: 0
    edited February 2022

    @colin Included the processing library in this updated test case: live.datatables.net/zopihoki/1/edit

    Not sure how to make the processing indicator appear when stateRestore is loaded. I added the processing code into stateLoadParams.

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

    You're using table in stateLoadParams, but table has been created at that point, using the settings to get an API handle:

                var table = new $.fn.dataTable.Api( settings )
    

    See here,

    Colin

  • trongarttrongart Posts: 222Questions: 51Answers: 0
    edited February 2022

    @colin Thank you very much- this makes sense.

    It starts the processing indicator only after a state is loaded and not after the button to load a state is clicked (such as State 1). It's too quickly to notice in the test case, but this happens in larger tables. Is it possible to make the processing indicator run once a button within stateRestore is clicked?

    The processing indicator also no longer runs when the table is loaded for the first time until it stops loading (verified in my project).

  • trongarttrongart Posts: 222Questions: 51Answers: 0

    In the test case, if you choose 6+ items with the searchBuilder, save the search with stateRestore, then reload the page and load the "test state" from stateRestore, it is possible to see that the processing indicator only appears after all results are loaded instead of when the "test state" button is clicked.

  • trongarttrongart Posts: 222Questions: 51Answers: 0

    @colin Is there maybe a way to call the processing indicator specifically any time the
    stateRestore.state().load() API is used?

    My thinking is that in this case, the processing indicator will show once a stateRestore state button is clicked to load, but not sure if it is possible to do it this way.

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

    No, there isn't a callback for you to do that. You may be able to create a click event on the button, but not sure what the selector would be for that,

    Colin

  • trongarttrongart Posts: 222Questions: 51Answers: 0

    Would it work by using a custom button as I could do something as below:

    new $.fn.dataTable.Buttons( table, {
        buttons: [
            {
                text: 'Custom StateRestore',
                action: function ( e, dt, node, config ) {
                     table.processing(true);
                     setTimeout(function () {
    
                    //is it possible to run savedStatesCreate here just as the below?
                    //$.fn.dataTable.ext.buttons.csvHtml5.action.call(this, e, dt, node, config);
    
                    }
                    table.processing(false);
                    }, 0);
            }
        ]
    } );
    
  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    That might work, give it a try! :)

    Colin

  • trongarttrongart Posts: 222Questions: 51Answers: 0

    Just not sure how to call savedStatesCreate in a custom button such as:

    $.fn.dataTable.ext.buttons.csvHtml5.action.call(this, e, dt, node, config);

    Is there a way?

  • desperadodesperado Posts: 159Questions: 33Answers: 4

    @trongart Did you every solve this? I am having the same issue. When stateRestore state is selected the stateRestore menu remains displayed for over 6 seconds before dropping when I have 8000 rows of data.

Sign In or Register to comment.