filament table hidden record null
this is my code , I want to hidden table column with condition
the record always null
Solution:Jump to solution
So to manage the label, I use a description to clarify the data.
```php
TextColumn::make('stok_1')
->getStateUsing(fn (StockDigipos $record): int => $record->category === "PERDANA LITE" ? $record->stok_sp_ld : $record->stok_inj_357)...
10 Replies
You cant hide a column based on the record, it wont be able to create the table.
If you have 2 entries where one has the category and the other hasn't, how would you display the table
Here's a revised version of your question for the forum:
---
"I have a table in a Resource with the following columns:
And another set of columns:
If the category is
PERDANA LITE
, I only want to show the first set of columns and hide the second set. Conversely, if the category is VOUCHER
, I want to show only the second set of columns. How can I achieve this?"I dont think that you can.
if one record has PERDANA LITED and the record below has VOUCHER
The table cant render both columns in the same place
Maybe create an extra resource where you filter the query using based on the category:
https://filamentphp.com/docs/3.x/panels/resources/listing-records#customizing-the-table-eloquent-query
As Marco said: You cannot hide columns based on the record. If you always have the same amount of columns you can swap the content though:
But you will loose sortable functionality
thanks @Marco and @Dennis Koch .
with this code I Have problem with the Label
Solution
So to manage the label, I use a description to clarify the data.
This explanation highlights the purpose of the
description
, emphasizing that it provides clarity regarding the data associated with each label.You can just set the
->label()
But I want label with condition 😆, and I can do that with label .
Ah yeah. Probably doesn't work. So if description works, that makes sense.
Yes, but thank @Dennis Koch for your help 👌