与人交谈一次,往往比多年闭门劳作更能启发心智。思想必定是在与人交往中产生,而在孤独中进行加工和表达。 ——列夫·托尔斯泰

新闻资讯

yii2.0 GridView如何自定义按钮和链接
admin
发布时间:2015-07-21
关注度:241355

<?= GridView::widget([
        'dataProvider' => $dataProvider,
        //'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            //显示的字段
            //code的值
            ['attribute'=>'这是测试code','value'=>function(){return 'abc';}],
            'name',
            'population',
            
            ['class' => 'yii\grid\ActionColumn','header' => '操作',],
            [
                'label'=>'更多操作',
                'format'=>'raw',
                'value' => function($data){
                    $url = "http://www.baidu.com";
                    return Html::a('添加权限组', $url, ['title' => '审核']); 
                }
            ]        
        ],
    ]); ?>