URL in Yii2 GridView

后端 未结 8 1838
后悔当初
后悔当初 2020-12-15 15:09

I have this code:

 $dataProvider,
  \'filterModel\' => $searchModel,
  \'columns\' => [
    [\         


        
相关标签:
8条回答
  • 2020-12-15 15:41

    solution:

    <?=  GridView::widget([
           'dataProvider' => $dataProvider,
           'filterModel' => $searchModel,
           'columns' => [
           ['class' => 'yii\grid\SerialColumn'],
                 [
                 'label'=>'bla',
                 'format' => 'raw',
                 'value'=>function ($data) {
                            return Html::a(['site/index']);
                          },
                 ],
         ['class' => 'yii\grid\ActionColumn'],
      ],
    ]); ?>
    
    0 讨论(0)
  • 2020-12-15 15:43

    try this one if you need to make the attribute as label :

    [
     'label'=>'' ,
     'header'=>Yii::t('app', 'Sample Number'),
     'attribute'=>'sample_number',  
                      'width'=>'310px',
                      'value' => function ($model) {
                              return Html::a(Html::encode( $model->sample_number), 
                              Url::to(['controller/action', 'sample_number' => $model->sample_number]));
                          },
     'format' => 'raw',     
     'options'=>['class'=>'success','style'=>'font-weight:bold;'],
    ],
    
    0 讨论(0)
提交回复
热议问题