#Persist toggleable column state between sessions

13 messages · Page 1 of 1 (latest)

static wadi
#

Hello,
It is a way to persist the toggled state of a column?
Some of my users want to see their data by default deferently from others but I cannot find a way to persist their table.
Is it possible?

hollow craterBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

karmic fjord
static wadi
#

No:
I have a table with these data:
name | surname | created_at | updated_at

some users want to see only
name | created_at

others want to see:
name | surname | updated_at

etc...

Each user can set it via the icon on the right of the table, but as soon as, they loggout they have to set it again.

Is there a way to persist their choice?

karmic fjord
#

alright now i understand what your looking for. i've done a little research on this and i haven't found a built in functionality for this use case.

what i've found is the part in the app where the visible columns are determined. that should be this method here:

https://github.com/filamentphp/filament/blob/3.x/packages/tables/src/Table/Concerns/HasColumns.php#L101

GitHub

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament

#

maybe this will help you a little

steady stone
uncut quail
#

I hate to reopenin this, but are toggle-able states really not persistent unless using hidden by default? Seems like a frustrating experience if a user hides columns and then any refresh brings them back.

steady stone
uncut quail
#

Hmm, mine aren’t persisting on refresh. Will open a separate thread for that

ebon solstice
#

any update?

#

is there a way to get the state of the toggleable column state so I can save it in the cache?

ebon solstice
#

Only solution I found

    /**
     * @return void
     */
    public function updatedToggledTableColumns(): void
    {
        Cache::forever('user-toggle-' . $this->record->id, $this->toggledTableColumns);

        session()->put([
            $this->getTableColumnToggleFormStateSessionKey() => $this->toggledTableColumns,
        ]);
    }

then

                        $toggleState = Cache::get('user-toggle-' . $this->record->id);

                        if ($toggleState) {
                            return !$toggleState['full_name'];
                        }

                        return false;
                    })