首頁  >  文章  >  後端開發  >  yii 2.0 GridView-自定义按钮跟链接

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

WBOY
WBOY原創
2016-06-13 12:11:46949瀏覽

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>?>

效果如图:

 

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn