如何在Yii2中创建网格视图(点击列表中的特定ID后打开该ID的所有细节)?

时间:2015-12-14 10:18:32

标签: php yii2

在Member模块的index.php中,我点击了id后打开了这个小部件来打开详细信息。但是这里打开一个Url代码,因为它不是url page.please给我解决方案。并建议我使用,因为我不熟悉Yii2。

             <?= GridView::widget([
                'dataProvider' => $dataProvider,
                'filterModel' => $searchModel,
                'columns' => [
                    ['class' => 'yii\grid\SerialColumn'],
               [
                   'label'=>'practiceCode',
                   'format' => 'url',
                   'value'=>function ($data) {
                   return Html::a(Html::encode("View"),'practice/view');
                },
            ],


                    'memberCode',
                    'firstName',
                    'lastName',
                    'email:email',
                    'mobile',

                    ['class' => 'yii\grid\ActionColumn'],
                ],
            ]); ?>

2 个答案:

答案 0 :(得分:1)

<?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
       [

           'lable'=>'practiceCode',
           'format' => 'raw',
           'value'=>function ($model, $index, $widget){
            return Html::a($model->practiceCode,['practice/view','id'=>$model->practiceCode],['title'=>'Go!','target'=>'_blank']
            );
    // return Html::a(Html::encode("View"),'practice/view');
   // return Html::a(Html::encode($data- >practiceCode),'practice/view');

        },
    ],

答案 1 :(得分:1)

现在它正在运行'attribute'=>'practiceCode'而不是'lable'=>'practiceCode',