This example describes the yii2.0 custom button and link usage for the GridView. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
<?= Gridview::widget ([
' Dataprovider ' => $dataProvider,
' Filtermodel ' => $searchModel,
' Columns ' => [
[' Class ' => ' Yii\grid\serialcolumn '],
Fields that are displayed
The value of the code
[' attribute ' => ' This is Test code ', ' Value ' =>function () {return ' abc ';}],
' Name ',
' Population ',
[' Class ' => ' Yii\grid\actioncolumn ', ' header ' => ' operation ',],
[
' label ' => ' more operations ',
' Format ' => ' raw ',
' Value ' => function ($data) {
$url = "http://www.baidu.com";
Return html::a (' Add Permission Group ', $url, [' title ' => ' Audit ']);
}
]
],
]);?>
The effect is as shown in the following illustration:
I hope this article will help you with the PHP program design based on the YII framework.