Home  >  Article  >  php教程  >  yii2.0之GridView自定义按钮和链接用法,yii2.0gridview

yii2.0之GridView自定义按钮和链接用法,yii2.0gridview

WBOY
WBOYOriginal
2016-06-13 09:18:501336browse

yii2.0之GridView自定义按钮和链接用法,yii2.0gridview

本文实例讲述了yii2.0之GridView自定义按钮和链接用法。分享给大家供大家参考。具体实现方法如下:

复制代码 代码如下:


        'dataProvider' => $dataProvider,
        //'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            //显示的字段
            //code的值
            ['attribute'=>'这是测试code','value'=>function(){return 'abc';}],
            'name',
            'population',
           
            ['class' => 'yii\grid\ActionColumn','header' => '操作',],
            [
                'label'=>'更多操作',
                'format'=>'raw',
                'value' => function($data){
                    $url = "http://www.baidu.com";
                    return Html::a('添加权限组', $url, ['title' => '审核']);
                }
            ]       
        ],
    ]); ?>


运行效果如下图所示:

希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn