Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug with the storage key saving for hidden columns and per page #604

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

Nowocyn
Copy link
Contributor

@Nowocyn Nowocyn commented Oct 26, 2023

The storage key for the hidden columns was created with $this->sessionStorageKey() and $this->name but only loaded by using $this->sessionStorageKey(). The same problem appeared with per page.
Old:

public function setSessionStoredHidden()
    {
       //...
        session()->put([$this->sessionStorageKey() . $this->name . '_hidden_columns' => $hidden]);
    }

public function initialiseHiddenColumns()
    {
     //...
        if (session()->has($this->sessionStorageKey() . '_hidden_columns')) {
            $this->columns = collect($this->columns)->map(function ($column, $index) {
                $column['hidden'] = in_array($index, session()->get($this->sessionStorageKey() . '_hidden_columns'));

                return $column;
            })->toArray();
        }
    }

Changed:

session()->put([$this->sessionStorageKey() . $this->name . '_hidden_columns' => $hidden]);

to

session()->put([$this->sessionStorageKey() . '_hidden_columns' => $hidden]);

Second change:

$this->perPage = session()->get($this->sessionStorageKey() . $this->name . '_perpage', $this->perPage);

to

$this->perPage = session()->get($this->sessionStorageKey() . '_perpage', $this->perPage);

@Nowocyn Nowocyn changed the title Fixed a bug with the storage key saving for hidden columns Fixed a bug with the storage key saving for hidden columns and per page Oct 26, 2023
@arm092
Copy link

arm092 commented Apr 6, 2024

Hey bro I've fixed this in my fork, also added Laravel 11 support

https://github.com/arm092/livewire-datatables/releases/tag/2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants