How do I dynamically create table columns in my admin panel?
My database table has
name
and value
columns. I currently use TextColumn
for both, like this:
How do I dynamically set the column for value
based on the value of name
?6 Replies
I checked the table API and can't find anything to help me with this. The only option seems to be custom column.
This feature is going to be similar to the form
schema
API that accepts a closure. This allows for dynamically setting form components at runtime. Tables' columns
seems to be a good candidate for this, unless I am missing something. Is a PR acceptable for this?Define you columns outside of the return then return the columns array as the the ->columns()
But how do I get access to the
$record
so I can inspect and define columns based on the row value?Good point. Tables aren’t the same as forms some things work with forms that don’t work with tables.
Just the nature of html.
Columns have to be more rigid because you run the risk of one row having a column and another not and that’s just not possible with html tables.
I understand your point. Thanks man
But I think it is doable. Will be a fun feature to play hack if allowed into the framework.
columns(array...)
currently accept only array of table columns. The new feature will simply allow closure columns(array... | callable...)
and the callable will return array of table columns.
Flexible like forms, preserves the behavior via different APIs.Maybe, but forms aren’t repeated data. They are set.
In regards to a table, every record has to have the same fields / columns.
Even if the value of that column is null.