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 option to set hideable columns #24

Closed Najiva closed 1 year ago

Najiva commented 3 years ago

Currently all of the columns are able to be hidden away. I wanted to be able to only allow hiding some of them.

Method like self.set_hideable_columns(['A', 'B']) could do that.

Najiva commented 3 years ago

I have suggested the solution. How do I make a pull request?

djk2 commented 3 years ago

Hi Najiva, will be great if you can make your own PR.

  1. First of all, if you want prepare a PR to django-tables2-column-shifter you must fork my project. In right-top corner you should have button fork 2.Clone it to your local system.
  2. Make a new branch. issue#24-hideable-columns
  3. Make your changes.
  4. Push it back to your repo.
  5. Click the Compare & pull request button.
  6. Click Create pull request to open a new pull request.

In my opinion new attr must be add:columns_allow_to_hide or hideable_columns to class ColumnShift. By default all columns should be available to hide (back compability). This new attribute by default should be None or list of all columns Logic for new attribute and for existing one column_default_show should be consest - some validation should be add.

From UI point of view this columns still will be shown but won't be active (gray)

Tests must be added.