逐行css表达式的正确方法是什么.在Yii 1中是rowCssClass.我无法弄清楚如何用Yii2实现这一目标.我试过这个,但不确定我是在正确的路线上:
'rowOptions' => function($model, $key, $index, $grid){
if($data->option->correct_answer == 1){
return ['class' => 'danger'];
}
},
Run Code Online (Sandbox Code Playgroud)
我不确定在处理dataProvider时从哪里获取函数的参数.
use*_*788 26
使用$ model代替$ data.
在我的变体中:
'rowOptions' => function ($model, $index, $widget, $grid){
return ['style'=>'color:'.$model->status->color.'; background-color:'.$model->status->background_color.';'];
},
Run Code Online (Sandbox Code Playgroud)
在你的情况下:
'rowOptions' => function ($model, $index, $widget, $grid){
if($model->option->correct_answer == 1){
return ['class' => 'danger'];
}else{
return [];
}
},
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
20845 次 |
最近记录: |