我使用ArrayDataProvider
public function actionIndex()
{
$data = order::getSome();
$dataProvider = new ArrayDataProvider([
'allModels' => $data,
'sort' => [
'attributes' => ['order_customFields_delivery_method']
],
'pagination' => [
'pageSize' => 50,
],
]);
return $this->render('index',['dataProvider' =>$dataProvider]);
}
如何根据条件更改gridview中字符串的颜色?像这样的东西^
<?= GridView::widget([
'dataProvider' => $dataProvider,
'formatter' => ['class' => 'yii\i18n\Formatter', 'nullDisplay' => ''],
'filterModel' => $searchModel,
'rowOptions' => function ($model)
{
if($model->order_customFields_delivery_method == 'eu-multi'){
return ['class'=>'success'];
}
},
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'order_customFields_delivery_method',
答案 0 :(得分:0)
'rowOptions' => function($data)
{
if($data['order_customFields_delivery_method'] == 'eu-multi'){
return ['style' => 'background-color:#FFB6C1;'];
}
},