Can I bulk submit column visibility?

Can I bulk submit column visibility?

kdorffkdorff Posts: 16Questions: 0Answers: 0
edited May 2012 in DataTables 1.9
I am using DataTables 1.9.1.

I am working with some tables that are very wide (100+ columns). Datatables seems to be handling this OK so far (I'm still experimenting). One question that I have, though, has to do with column visibility. I looked at ColVis and while it works, it isn't really designed for tables with lots of columns. The list is visually unwieldy and hiding/showing on each click is very slow).

So I wrote my own column chooser using a component I've used before (a modified version of jQuery DualList). I have it working to my liking. I make the changes to my column choices and click one button and it executes oTable.fnSetColumnVis() for column for which visibility has changed (either hidden or unhidden). If you are showing or hiding a lot of columns, this can still be pretty slow. This slowness is compounded by the fact that DataTables is round-tripping to the database for each column visibility change. I am using Scroller so the amount of data for each transfer isn't huge, but if I hide 25 columns it goes across the network 25 times to grab the data again and again.

When I load data from the server, it shows "Processing". My first question is: Is there some way to display this as I am showing/hiding the columns so the user doesn't thing the browser has just stopped?

One performance possibility I am wondering about might be if there was a way to tell DataTables I am going to be changing a number of things, please don't redraw until I tell you I'm done. With most UI development, there is a way to turn off redraw if you are making a lot of changes and then turn redraw back on. This can greatly improve performance. Is there something like this with DataTables that I can use? Alternatively, a way to bulk change column visibility (some on, some off) so this all gets set at once and DataTables doesn't have to make a bunch of throw away round trips to the database. I looked for a API call do do something along these lines but I didn't see anything.

Thanks!
Kevin

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > One performance possibility I am wondering about might be if there was a way to tell DataTables I am going to be changing a number of things, please don't redraw until I tell you I'm done.

    Since you are using fnSetColumnVis - pass the third parameter as false and then call fnDraw when you are all done :-)

    > When I load data from the server, it shows "Processing". My first question is: Is there some way to display this as I am showing/hiding the columns so the user doesn't thing the browser has just stopped?

    http://datatables.net/plug-ins/api#fnProcessingIndicator :-)

    Regards,
    Allan
  • kdorffkdorff Posts: 16Questions: 0Answers: 0
    Thank you so much for responding. These should help.
This discussion has been closed.