yii2.0 the GridView Custom button and link usages _php instance

Source: Internet
Author: User
Tags yii

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.