columnsToggle and colReorder not working

columnsToggle and colReorder not working

GryphonnGryphonn Posts: 4Questions: 0Answers: 0

Hello!
I'm using the columnsToggle button but I want to prevent one particular column from toggling (it should always be visible).

I gave this column a class name (always) and then excluded it in the buttons section:

buttons: [
{
extend: 'columnsToggle',
columns: ':not(.always)'
}],

Everything works fine until I reorder columns. The problem is that during initializing it gets a column index by the class name and then hide it. But after reordering it hides another column with the same index exposing my hidden column.
One more time. It gets an index number by the class name, excludes it, but then only cares about this index (not a class name).

I need the column exclusion work after reordering as well. Any solution?

My website
https://halfin.ru/data2/

Try to move the ticker column and it will show up in the toggle section.

Replies

  • allanallan Posts: 63,226Questions: 1Answers: 10,416 Site admin

    Can you give me step by step instructions on how to show the issue please? It looks like "Ticker" is the column with the always class and that sames to say as far as I can tell and it updates correctly when clicked on in the bar.

    Allan

  • GryphonnGryphonn Posts: 4Questions: 0Answers: 0
    edited March 2021
    1. It mustn't be in the toggle bar. This is the whole point. I don't want users to toggle this column. But after reordering it shows up. I don't know how to explain it better so I recorded a video.

    2. I found another bug. When using groups buttons the toggle bar doesn't update immediately. It's on the video too.

    Thanks.

  • GryphonnGryphonn Posts: 4Questions: 0Answers: 0

    @allan please check my comment above

  • GryphonnGryphonn Posts: 4Questions: 0Answers: 0

    @allan I solved the second problem.

  • allanallan Posts: 63,226Questions: 1Answers: 10,416 Site admin

    I see what you mean - apologies for misunderstanding before.

    You are correct, internally Buttons is translating the selector into a column index, which is what is causing this issue - when the columns are reordered it doesn't have access to the original selector, so the indexes get swapped around.

    There might be a way to make the hidden column never in the list, but rather than doing that, I would suggest actually not having that column. If you don't want it to be visible ever, and you are Ajax loading the table, then why bother making a column for it at all? The data will still be available using the API (e.g. rows().data().

    Allan

This discussion has been closed.