Responsive, Buttons and Colvis - Remove hidden columns from colvis

Responsive, Buttons and Colvis - Remove hidden columns from colvis

drblakldrblakl Posts: 1Questions: 1Answers: 0

Link to test case using 1.13.11: https://live.datatables.net/hucabomo/1/edit
Debugger code using 1.13.11: inivup

Link to test case using latest release: https://live.datatables.net/zilofacu/1/edit
Debugger code latest release (debug.datatables.net): udagaj

Error messages shown: No Error Message

Description of problem: I'd like to achieve functionality as it exists in 1.13.11 while using the latest libraries.

Desired Functionality:
1. OnLoad Visible columns are selected in the column visibility dropdown and those that aren't visible are not selected.
2. When expanding a row to view details all of the hidden columns are present. I believe we can use listHidden or listHiddenNodes to view just the hidden nodes.
3. When selecting a column from the column visibility dropdown to be visible that column is added to the datatable as expected.

In 1.13.11 when resizing the window or loading it appears that the 'column-visibility.dt' event is fired instead of the 'responsive-resize' event that was later added.

I've spent a little time trying to use the 'responsive-resize' event to change the visibility of the columns that are responsive hidden to not visible to ensure they're no longer selected within the column visibility dropdown. This works but then removes the responsive details column. Also not a fully implemented solution. Attached code that might be able to be updated. Resize to see results, onload functionality hasn't been implemented.

Link to test case using latest release: https://live.datatables.net/barezebe/1/edit
Debugger code latest release (debug.datatables.net): uwekas

Any and all guidance and help would be greatly appreciated!

Thank you!

Answers

  • allanallan Posts: 64,015Questions: 1Answers: 10,555 Site admin

    Hi! Thanks for the examples.

    Wow, that's an old version of Responsive you've got in the first example :).

    1. OnLoad Visible columns are selected in the column visibility dropdown and those that aren't visible are not selected.

    Responsive 1.x used the DataTables' column visibility controls to show / hide columns. That changed with 2.0.0 (in 2015!) when I changed it to use its own method of column hiding. The problem was that the overlap of two things controlling the visibility, caused all sorts of confusion. E.g. in your v1 example, "Start date" isn't hidden by the DataTable, but it is by Responsive. Changing the toggle in the dropdown actually breaks the layout and resize would hide it again. That's a bug that doesn't happen any more.

    1. When expanding a row to view details all of the hidden columns are present. I believe we can use listHidden or listHiddenNodes to view just the hidden nodes.

    With the newer releases, if a column is hidden by the DataTables API (which is what happens with the buttons) then it won't be shown in the Responsive list for the columns.

    1. When selecting a column from the column visibility dropdown to be visible that column is added to the datatable as expected.

    Per the above, that doesn't work any more.

    I'm afraid with the change in Responsive 2 (we are now at 3.0.3 at the time of writing this), the separation of Responsive's and DataTables' column hiding makes exactly what you are looking for with Responsive 1.x simply not possible I'm sorry to say.

    Allan

Sign In or Register to comment.