djk2 / django-tables2-column-shifter

Simple extension for django-tables2 can dynamically show or hide columns. Using JQuery, Bootstrap 3, Bootstrap 4, Bootstrap 5 and Django >=1.9
BSD 3-Clause "New" or "Revised" License
21 stars 8 forks source link

Add API for retrieving non-visible columns #9

Closed spapas closed 6 years ago

spapas commented 6 years ago

Hello, could you add a JS function for retrieving the non-visible column names?

Right now this could be done with JSON.parse(localStorage.getItem("django_tables2_column_shifter")) however I think it would be better if there was a global function (or maybe a method of $ like $.get_non_visibe_columns).

This would be very useful in case somebody wants to export only the visible columns when exporting the data, thus when the user clicks on the export button it would append an &excluded_columns=col1,col2 to the button's href which would then be used by the TableExporter: http://django-tables2.readthedocs.io/en/latest/pages/export.html#excluding-columns to exclude these cols, i.e something like

exporter = TableExport('csv', table, exclude_columns=self.request.GET.get('excluded_columns').split(',))

djk2 commented 6 years ago

Hey @spapas, Sorry for my delay. In now I'm really busy. Can you prepare Pull Request to my project or send few line of JS code?