In model I have function:
public function getResult($id)
{
$result = new \stdClass();
$result->alfa = $id.10;
$result->beta = $id.20;
$result->delta = $id.50;
return $result;
}
In grid view I'd like to call this function ONLY ONE time, but display each value in separate column. Now view looks like that:
[
...
[
'value' => function($item){
$res = $item->result();
return $res->alfa;
},
],
[
'value' => function($item){
$res = $item->result();
return $res->beta;
},
],
[
'value' => function($item){
$res = $item->result();
return $res->delta;
},
],
...
]
I've read, that there is no way to pass value from one column to another, but it should be some work around, right? So far I've tried to get values before columns and then add it like that: function($item) use ($result) {}, also called function from search model, but I can't (or just don't know how) pass values to them.
In 'real' model I get values with request - there is no way to split it, also, those calculations are quite complex, so I need to get rid of those multiple calls, because as you can imagine loading time is nasty with those extra calls
Thanks for any helpful info or ideas!