Open Nuranto opened 5 years ago
hmmm...why don't you just add the data on your class and use it as such on the grid attributes?
public function getStatuses() {
return ['0'=>'Pending', '1' =>'Processing']
}
Then on your grid,
[
"label" => 'Status',
'presenter' => function ($columnData, $columnName) {
return $this->getStatuses()[$columnData->status] ?? '';
},
"filter" => [
"enabled" => true,
'type' => 'select',
'data' => $this->getStatuses()
]
]
After all, the grid is just a normal class
That's what I'm doing actually (well, I trigger the values from another model, but whatever), I tried to simplify the example. But even like this, it is redondant and non-intuitive.
I think in 99% of cases, the 'data' of a select filter will be used in the presenter. So why don't make it as default ?
I agree it is a small enhancement for lazy/perfectionist devs :)
Ok, I'll add it as an option.
For the column :
The display in rows is 0 or 1. It would be nice if the default presenter took filter.data into consideration, and displayed automatically "Pending" or "Processing" (or empty if null value). At the moment, we need to do this :
which works, but is quite redundant.