Changing visibility, spinner for time consuming task

Changing visibility, spinner for time consuming task

hattabatattahattabatatta Posts: 1Questions: 1Answers: 0

Hey everyone.

I am using DataTables a while now and I am very happy with it.
For the company I m working for I have created a WebApplication (though I am NO webdeveloper ... I am more specialist in Serverapplications, Clustering and stuff)

Case:
I have a bigger DT View, where about 6.000 entries are shown.
I was able to show a spinner, and show the DT after everything is loaded, so the user will not see a blank screen and stuff.
So far so good.

The user should be able to change the visibility of the columns. Therefore I added the colVis function, which works as expected.
Also some columns are hidden by default and stuff.

The main problem is.
Depending of the visibility of the columns, the value of other columns are changing (dont ask why pls :D)
So I have to iterate through the whole table data and changing row by row manually, which is very time consuming, especially when there are a huge amount of rows.
I want to show the same spinner icon, as its shown of the initial load, but I have no clue how.

Please see the code fragment below of the operation.
The setDeltaStates() is the time consuming task, as showSpinner and hideSpinner should be self explaining :smile:

    table.on('column-visibility.dt',  function (e, settings, column, state) {

                    if (column == 8 || column == 10) {
                        showSpinner();
                        if (table.column(8).visible()) {
                             setDeltaStates(8);
                        }
                        if (table.column(10).visible()){
                            setDeltaStates(10);
                        }
                         hideSpinner();
                    }
                });

Can anyone help me?
I tried to set the methods async but that did not work (thrown some expections), but as I am not very firm in JavaScript (I am more into C, C++, python and C# to be honest) I ran out of ideas :(

Answers

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

    You can use the processing() plugin for that - that will give you an API call (table.processing() to enable/disable the processing indicator.

    See example here,

    Colin

Sign In or Register to comment.