直接貼程式碼吧:
<?= GridView::<span>widget([ </span>'dataProvider' => <span>$dataProvider</span>, <span>//</span><span>'filterModel' => $searchModel,</span> 'columns' =><span> [ [</span>'class' => 'yii\grid\SerialColumn'], <span>//</span><span>显示的字段 //code的值</span> ['attribute'=>'这是测试code','value'=><span>function</span>(){<span>return</span> 'abc';}], 'name', 'population',<span> [</span>'class' => 'yii\grid\ActionColumn','header' => '操作',],<span> [ </span>'label'=>'更多操作', 'format'=>'raw', 'value' => <span>function</span>(<span>$data</span><span>){ </span><span>$url</span> = "http://www.baidu.com"<span>; </span><span>return</span> Html::a('添加权限组', <span>$url</span>, ['title' => '审核'<span>]); } ] ]</span>,<span> ]); </span>?>
效果如圖:
以上就介紹了yii 2.0 GridView-自訂按鈕和鏈接,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。