yii 2.0 GridView-自定义按钮和链接
直接贴代码吧:
<?= GridView::<span style="color: #000000;">widget([ </span>'dataProvider' => <span style="color: #800080;">$dataProvider</span>, <span style="color: #008000;">//</span><span style="color: #008000;">'filterModel' => $searchModel,</span> 'columns' =><span style="color: #000000;"> [ [</span>'class' => 'yii\grid\SerialColumn'], <span style="color: #008000;">//</span><span style="color: #008000;">显示的字段 //code的值</span> ['attribute'=>'这是测试code','value'=><span style="color: #0000ff;">function</span>(){<span style="color: #0000ff;">return</span> 'abc';}], 'name', 'population',<span style="color: #000000;"> [</span>'class' => 'yii\grid\ActionColumn','header' => '操作',],<span style="color: #000000;"> [ </span>'label'=>'更多操作', 'format'=>'raw', 'value' => <span style="color: #0000ff;">function</span>(<span style="color: #800080;">$data</span><span style="color: #000000;">){ </span><span style="color: #800080;">$url</span> = "http://www.baidu.com"<span style="color: #000000;">; </span><span style="color: #0000ff;">return</span> Html::a('添加权限组', <span style="color: #800080;">$url</span>, ['title' => '审核'<span style="color: #000000;">]); } ] ]</span>,<span style="color: #000000;"> ]); </span>?>效果如图:

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号