我有一个列表页面,其中显示电子邮件列表,如果我想删除任何列表,我实际上并不删除它,但它在表格列中标记为已删除。
对于email_lists
我使用GridView小部件来显示列表,如果在表email_lists
中将其标记为已删除,我想要突出显示一行。
任何想法如何突出显示整行而不是列?
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'name',
'total_recipients',
'list_type',
// 'is_deleted',
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Actions',
'template' => '{update}{view_list}{delete}',
'buttons' => [
'view_list' => function($url, $data, $key) {
return Html::a('<i class="glyphicon glyphicon-eye-open"></i>', ['/promos/promolistemails/index', 'id' => $data->id], ['title' => 'View List Emails']);
},
'update' => function($url, $data, $key) {
if ($data->list_type == 'custom') {
return Html::a('<i class="fa fa-pencil"></i>', '#.', ['title' => 'Edit List Emails', 'data-url' => yii\helpers\Url::to(['/promos/promolists/update', 'id' => $data->id]), 'class' => 'edit-list']);
}
},
'delete' => function($url, $data, $key) {
if ($data->list_type == 'custom') {
return Html::a('<i class="fa fa-trash"></i>', $url, ['title' => 'Delete List', 'data-method' => 'post', 'id' => 'delete-list']);
}
},
]
],
],
]); ?>
答案 0 :(得分:1)
我需要将rowOptions
用于GridView
'rowOptions'=>function ($model, $key, $index, $grid){if($model->is_deleted){return ['class'=>'red'];}},
答案 1 :(得分:1)
试试这个
'rowOptions' => function($model, $key, $index, $grid){
if($model->is_deleted){
return ['class' => 'danger'];
}
},