Home > Backend Development > PHP Tutorial > yii 2.0 GridView-custom buttons and links

yii 2.0 GridView-custom buttons and links

WBOY
Release: 2016-08-08 09:32:35
Original
990 people have browsed it

Post the code directly:

<?= 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>?>
Copy after login

The effect is as shown in the picture:

The above introduces Yii 2.0 GridView-custom buttons and links, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template