Allow user to reorder and hide/unhide columns + state saving
Allow user to reorder and hide/unhide columns + state saving
Hi,
I'm using DataTables for my Trac watchlist plugin (http://trac-hacks.org/wiki/WatchlistPlugin), which
shows a list of watched wiki and ticket pages similar e.g. to the Wikipedia watchlists. The table data is inserted in the HTML page by the trac server and static for the client, i.e. not loaded by AJAX.
I would like to allow users of this plug-in to select the columns and their order using a simply interface, i.e.
drag & drop for the order and maybe some small delete/hide icon in the footer or header for every column.
The configuration should be saved and restored at the next visit.
So far I understand the internal of DataTables this should be possible to implement.
However, their seems no drag & drop plug-in for DataTables yet. Did anyone attempted to program something like the above and/or can give me some advice?
The alternative would be to provide a settings form for this, store the configuration on the trac server and deliver the table with the selected columns.
I'm using DataTables for my Trac watchlist plugin (http://trac-hacks.org/wiki/WatchlistPlugin), which
shows a list of watched wiki and ticket pages similar e.g. to the Wikipedia watchlists. The table data is inserted in the HTML page by the trac server and static for the client, i.e. not loaded by AJAX.
I would like to allow users of this plug-in to select the columns and their order using a simply interface, i.e.
drag & drop for the order and maybe some small delete/hide icon in the footer or header for every column.
The configuration should be saved and restored at the next visit.
So far I understand the internal of DataTables this should be possible to implement.
However, their seems no drag & drop plug-in for DataTables yet. Did anyone attempted to program something like the above and/or can give me some advice?
The alternative would be to provide a settings form for this, store the configuration on the trac server and deliver the table with the selected columns.
This discussion has been closed.
Replies
Regards,
Allan
I now implemented the column reordering on the server side. Because I allow the user to switch dataTable off and only work with a static table this is actually better.
I also added individual column filtering to it and use the 'save state' option to preserve the column filtering.
Now my new problem: When the user uses a form to change the columns, the page reloads with the new column order, but dataTable then applies the filter text to the wrong columns, i.e. does this strictly by index.
Is there a way to tell dataTable to do this by e.g. looking on the table headers?
My workaround is that the form submit functions simply deletes the column filter text. This avoids the issue of wrong filter texts in the columns, but means that the user looses them when he/she updates the column order. Ok, not really a big deal, but if there is a way to make it even more user friendly I would like to go it.
Regards,
Allan
Now the current problem:
When the user changes the order of columns I need to make sure, that the current state of the table isn't stored in a cookie and that the old cookie is deleted. Is there a way to disable the "save state" feature on demand? Is it enough to access oSettings in the submit function of the 'Change Column Order' form and switch the bSaveState off?
Allan
I already wrote a function to delete existing cookies before.
The new information (new column order) coming from the server so I need to reload the entire page.
I will now write a function to set bStateSave to false and delete the existing cookie when the user changes the column order.
Thanks a lot,
Martin
Allan