Errors in table builder with a livewire component.
Hi, I am experiencing several problems with the Table Builder on a custom page.
I have a custom page in which I have added a livewire component that I have made following the documentation you have to build a table.
One of the problems is that when I select a row to be able to execute the bulk action, all the rows are selected, and when I try to deselect one, they are all deselected. It is impossible to select 1 single row.
Another problem I'm experiencing is that simple actions that have ->form() and ->requiresConfirmation() don't open modal.
13 Replies
Can you share some code?
And also check your browser console for notices/errors
No errors on the browser console
Try commenting out that getTableRecordKey method.
When I comment it, it trows an error
This is the response of the request of the action with modal.
Other problem that I'm getting is when I search in the serchable column, it duplicates some records on the table
Something weird is going on, because you should not have to implement getTableRecordKey(), the default implementation should handle it.
But the reason all your records are being selected is that you are giving them all the same key value. That function should return something like $record->id, ie. the primary key value, not a static string.
You do have a PK set on that model / table, right?
The PK of that model is the path, but I don't want to show the path in the table, I just want to show the name and the number of screenshots it has.
with this, it works
and the problem of the searchable colum is solved
It only remains to solve the problem with the simple actions modal
You get the erro getTableRecordKey because your relationship has returned null or you have an incorrect relationship, i.e. hasMany oppsed to belongsToMany
Don't think he's using any relationships. It's just a simple table with two fields. And he shouldn't have to implement that function.
I think it may be something to do with the select on the getTableQuery, which is probably forcing the query to only return those two fields, and not the PK.
@jals65 - even if you aren't displaying the PK, it still needs to be selected, so Filament has the id.
Also, can't you just cast that JSON field in the model, rather than doing a JSON select by hand?
I just did tests and that is why, if I return the path in the query, it does allow me to comment on the getTableRecordKey function
Since I wasn't returning it, it couldn't find it
About the problem with the simple actions modal, do you know anything?