Home  >  Article  >  Backend Development  >  yii 2.0 GridView-自定义按钮跟链接

yii 2.0 GridView-自定义按钮跟链接

WBOY
WBOYOriginal
2016-06-13 12:11:46948browse

yii 2.0 GridView-自定义按钮和链接

直接贴代码吧:

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

效果如图:

 

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