我需要在同一列中添加序列类和复选框类。请尽快帮助我。谢谢...
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\CheckboxColumn',
'header' => '',
'checkboxOptions' => function($model) {
if($model->featured=="Y"){
$bool =true;
}else{
$bool =false;
}
return ['checked' => $bool,'value'=>$model->user_id];},'contentOptions' => ['style'=>'text-align: center;font-size: 13px;',],
],
['class' => 'yii\grid\SerialColumn',
'header' => 'S.No',
'headerOptions' => ['style'=>'text-align: center;background-color: #868686;color: white;font-size: 13px;font-weight: bold;',],
'contentOptions' => ['style'=>'text-align: center;font-size: 13px;',],
],
], ]); ?>
答案 0 :(得分:0)
Coud你需要格式=&gt;原始和使用匿名函数的价值像这个建议
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\CheckboxColumn',
'header' => '',
'format' => 'raw',
'value' => function($model, $key, $index) {
return "<input type='checkbox' name='select[]' ><span> <?= $index ?></span>"
},
....
],
.....
], ]); ?>