我的GridView
中有4列,其中包含我需要的数据,但现在我还需要一列。如何在我的GridView
中创建它?
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
'surname',
'employment_date',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
感谢您的帮助
答案 0 :(得分:0)
您可以根据yii api添加更多列:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
'surname',
'employment_date',
[
'class' => DataColumn::className(), // this line is optional
'attribute' => 'name',
'format' => 'text',
'label' => 'Name',
],
['class' => CheckboxColumn::className()],
['class' => 'yii\grid\ActionColumn'],
]
]); ?>
您可以阅读this link
答案 1 :(得分:0)
<?= GridView::widget([
....
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
'surname',
'employment_date',
'columns'=>[
'attribute'=>'New Column',
'value'=>'tbl.new_column'
],
//OR This
new_column,
['class' => 'yii\grid\ActionColumn'],
],
]); ?>