Problem/Motivation

There is a problem with the Hidden and Expandable Columns. It works correctly only when all columns are in status "visible".

Steps to reproduce

1. Create a view, and choose format as Datatables.
2. Add fields title, content type, and counter.
3. Go to the Datatable settings > Hidden and Expandable Columns.
4. Change the title to Expandable, apply, and save it. Check the live page. It should work correctly.
5. Change the type to Expandable, apply, and save it. Check the live page, and it broke. The type is doubled. (screenshot attached)

How to make it work correctly?
Change all fields to visible, apply, and save it. Change Type and Title to Expandable at once, apply, and save it. It works correctly now.

Proposed resolution

Update the logic of the Expandable fields.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#2 datatables_bug.png48.58 KBjust-me

Issue fork datatables-3590430

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

just-me created an issue. See original summary.

just-me’s picture

StatusFileSize
new48.58 KB

just-me’s picture

First of all, I've merged the parent branch(from jQuery to Vanilla JS).

Figured out the main problem was related to the localStorage.
More info about stateSave here - https://datatables.net/reference/option/stateSave#Examples
So, as I've written in a file, all what needs:

// Remove the 'visible' property from the state data before it is saved to localStorage.
// This ensures column visibility is always controlled by Drupal Views, preventing
// cached browser states from overriding server-side configuration changes.
            currentSettings.stateSaveParams = (dtSettings, data) => {
              data.columns.forEach((col) => {
                delete col.visible;
              });
            };
          }
just-me’s picture

Assigned: just-me » Unassigned
Status: Active » Needs review
quadrexdev’s picture

Looks good

just-me changed the visibility of the branch 3590430-incorrect-work-of to hidden.

just-me changed the visibility of the branch 3590430-incorrect-work-of to active.

just-me’s picture

Status: Needs review » Fixed

Merged to 2.x, thanks to everyone.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.