jschmuff
(Jschmuff)
September 5, 2013, 4:29pm
1
So I declare a variable $time and pass it to the view. In the GridView columns array I am highlighting specific fields by date in cssClassExpression.
// View code snippet inside GridView widget
'cssClassExpression' => '($data->end_date <= $time) ? "highlight" : ""'
Not sure why $time is showing undefined since I pass it through render as ‘time’ => date(…),
Anyone able to shed some light here on the issue or how I can move past this. Thanks in advance.
BlkRaven
(Renity1001)
September 5, 2013, 4:59pm
2
Hi, try
'cssClassExpression' => '($data->end_date <= "'. $time .'") ? "highlight" : ""'
The cssClassExpression only recognises $row, $data and $this so any other variable being passed to cssExpression has to be concatenated as shown in the code.
jschmuff
(Jschmuff)
September 5, 2013, 5:01pm
3
I solved it was the duh… moment of my day.
'cssClassExpression' => ('$data->end_date' <= $time) ? '"highlight"' : '""',
Edit: I did however try the above mentioned throws this Parse error.
Parse error: syntax error, unexpected ‘19’ (T_LNUMBER) in C:\var\www\libphp\yii\framework\base\CComponent.php(612) : eval()'d code on line 1
BlkRaven
(Renity1001)
September 5, 2013, 5:09pm
4
I solved it was the duh… moment of my day.
'cssClassExpression' => ('$data->end_date' <= $time) ? '"highlight"' : '""',
Edit: I did however try the above mentioned throws this Parse error.
Parse error: syntax error, unexpected ‘19’ (T_LNUMBER) in C:\var\www\libphp\yii\framework\base\CComponent.php(612) : eval()'d code on line 1
I noticed the error. It appears you read my post while I was correcting it.