F
Filamentβ€’2mo ago
ericmp

Grid view loses headers

https://filamentphp.com/docs/3.x/tables/layout#arranging-records-into-a-grid When i use the grid layout, then the table loses the headers. In my case, I need to show to the user the field names of the values that are being shown in each record in the grid for example: table mode:
id n cp
2 4 45
[more rows here]
[more rows here]
id n cp
2 4 45
[more rows here]
[more rows here]
in grid mode:
2 34 more columns here
4 5
45 1
2 34 more columns here
4 5
45 1
in this grid mode, the user has to remember which field name is which one, otherwise they see only numbers so id like to achieve something like this:
id id
2 34 more columns here

n n
4 5

cp cp
45 1
id id
2 34 more columns here

n n
4 5

cp cp
45 1
should i use an infolist for that somehow? what should i do?
11 Replies
ericmp
ericmpβ€’2mo ago
so far im thinking of putting a tooltip each field with it's key, not sure though
Vp
Vpβ€’2mo ago
Not sure whether this will work or not cause i've never try grid table, but you can tweak like this maybe
TextColumn::make('id')
->formatStateUsing(fn (string $state) => "ID: {$state}")
TextColumn::make('id')
->formatStateUsing(fn (string $state) => "ID: {$state}")
ericmp
ericmpβ€’2mo ago
yeah well for simple text columns it'll do it, but in reality i have a lot of diff types of columns and this wont solve it. in the example i just did it with simple texts to create a minimal example
ericmp
ericmpβ€’2mo ago
hmm prolly that is a way yeah thanks. i think ill build a custom view. but if there are other ways let me know πŸ™ , cuz this one seems it adds a lot of complexity, i have to control it everything in the view & customize it a lot
Vp
Vpβ€’2mo ago
Yeah sure, but I think grid table isn't design for what you expected
cuz this one seems it adds a lot of complexity
I didn't see the complexity, all you have to do is define one view file, and inside the view, place data how you'd like to display, that's all... you don't need to create different views for different columns cause you got the whole record so one view file is enough for one resource
ericmp
ericmpβ€’2mo ago
yeah maybe. i thought like a grid view of some sort of infolists but i mean, for example, lets say i have a toggle column, how do i put it in a custom view while letting it to work? is that possible and idk, badge columns, yeah i can replicate them i guess inspecting the code and copying the html structure & css but idk πŸ€·β€β™‚οΈ i feel i'll struggle trying to set it all up or maybe not but idk how to achieve it so far yet & gotta dig deeper
Vp
Vpβ€’2mo ago
Oh.. I'll struggle too if I try to make toggle 🀣 but for badge, you can simple copy paste this (https://filamentphp.com/docs/3.x/support/blade-components/badge)
Vp
Vpβ€’2mo ago
Overall I'll use normal table if I need some extra works (like toggle) and use grid to display only some data and handle everything in form Checkout this Blade components (https://filamentphp.com/docs/3.x/support/blade-components/overview) it's easy to copy-pase if custom views is needed
ericmp
ericmpβ€’2mo ago
yeah that is cool, defo this is the workaround i think yeah so thanks again, u gave some path to me to follow!