rappasoft / laravel-livewire-tables

A dynamic table component for Laravel Livewire
https://rappasoft.com/docs/laravel-livewire-tables/v2/introduction
MIT License
1.78k stars 337 forks source link

Randomly dissappearing columns #760

Closed Ceepster14 closed 2 years ago

Ceepster14 commented 2 years ago

Hi,

First off, great package!

We're using livewire tables (currently 20+ cruds) extensively thoughout a new project and are experiencing issues with columns not showing by default in the tables. Sometimes one or two columns will display, sometimes all columns will display and sometimes no columns at all will display.

I've tried adding $this->setColumnSelectStatus(true); into the configure method, but this doesn't appear to have any effect.

One possible thought is quite a few of the tables contain the same column names i.e. title, description, enabled etc and I notice that you're creating the session key by md5 hashing the column name, so I don't know whether this might be affecting things?

Any thoughts?

rappasoft commented 2 years ago

Oof I didn't think of that and you are probably right. Can you do some testing with your app across tables and verify? I.e. disable 'name' and see if its hidden on all of your tables?

Ceepster14 commented 2 years ago

Hi Anthony,

Yes - that seems to be one of the 'gotchas' when using columns with the same name across different tables.

However I don't think it's the only gremlin lurking in there. Hopefully this might point in a helpful direction as this appears to be repeatable:

Take two of the tables in the application, one called Currencies and one called Colleges

The Cruds are setup using the following config:

Currency

public function columns(): array
    {
        return [
            Column::make("Currency", "currency")
                ->sortable()
                ->searchable(),
            Column::make("Symbol", "currency_symbol")
                ->sortable()
                ->searchable(),
            BooleanColumn::make("Default", "is_default")
                ->sortable(),
            Column::make("",'id')
                ->view('crm.settings.currencies.currency_list_actions')
                ->excludeFromColumnSelect(),
        ];
    }

College

public function columns(): array
    {
        return [
            Column::make("Name", "name")
                ->sortable()
                ->searchable(),
            Column::make("Address", "address")
                ->sortable()
                ->searchable(),
            Column::make("Postcode", "postcode")
                ->sortable()
                ->searchable(),
            Column::make("City", "city")
                ->sortable()
                ->searchable(),
            Column::make("Country", "country.country")
                ->sortable()
                ->searchable(),
            Column::make("Study type", "study_type")
                ->sortable(),
            Column::make("",'id')
                ->view('crm.settings.college_locations.college_locations_list_actions')
                ->excludeFromColumnSelect(),
        ];
    }

If I log out of the app and make sure the session cookie is cleared, then log back in:

I first visit the Currency Crud and all three columns are displayed. I then visit the the Colleges Crud and none of the columns are displayed

I then log out, clear the session cookie and log back in:

I first visit the Colleges Crud and all the columns are displayed. I then visit the the Currency Crud and none of the columns are displayed

For further fun, if I then add $this->setColumnSelectStatus(false); to the config for the currency crud and refresh the page, all the columns for Currency get displayed, but all the columns on the Colleges crud disappear again!

Hopefully this is going to start a bell ringing? If not, I apologise in advance for ruining your evening!

rappasoft commented 2 years ago

Haha nope not off the top of my head, I'll have to recreate and dig into it.

Thanks for finding it though.

inmanturbo commented 2 years ago

@rappasoft I can't help but wonder if putting the column selections into the query string instead of the session might fix this.

rappasoft commented 2 years ago

Probably, but right now I use hashes for some reason, and 10 of them in a query string array is really ugly so I need another solution.

rubensrocha commented 2 years ago

@rappasoft Any progress on fixing this issue?

rappasoft commented 2 years ago

Sorry, I've been sick for 3 weeks straight and haven't worked on anything. I'll get back to it soon.

wanadri commented 2 years ago

Hi @Ceepster14 , have you try the same concept as different table in same page?

by putting this public string $tableName = 'users'; in each class.

I have try this, and its working on my side.

Ceepster14 commented 2 years ago

Hi @wanadri,

Will give it a try if I get a chance and report back.

Thanks

rubensrocha commented 2 years ago

Hi @Ceepster14 , have you try the same concept as different table in same page?

by putting this public string $tableName = 'users'; in each class.

I have try this, and its working on my side.

Setting this property seems to solve the problem of columns with the same names on different pages being hidden for no reason.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.