zoukankan      html  css  js  c++  java
  • YII2 Gridview

    YII2 Gridview 部分使用规则

    1.页面显示的时间戳转换
    a.

    [
            'label'=>'创建日期',
            'attribute' => 'created_at',
            'filter' => false, //不显示搜索框
            'value' => function($data) {
                   return date('Y-m-d H:i:s',$data->created_at); }
    ],
    

    b.

    [
            'label'=>'创建日期',
            'attribute' => 'created_at',
            'format' => ['date', 'php:Y-m-d H:i:s'],
    ],
    

    2.为字段加超链接

    [ 
          'attribute'=>'title’,
          'format'=>'raw’,
          'value'=> function($data){return Html::a($data->title,['exam/index', 
                'id' => $data->_id],['title' => '审核']);} 
    ],
    
    [
         'label'=>'更多操作’, 
         'format'=>'raw’,
         'value' => function($data) { 
               $url = "http://www.baidu.com”; 
               return Html::a('添加权限组', $url, ['title' => '审核']); } 
    ],
    

    3.下拉菜单搜索

    [
                'label' => '当前状态',
                'attribute' => 'status',
                'filter' => Html::dropDownList('AppBaseSearch[status
    ]',$searchModel-> status,
                        [ '' => '请选择',
                        ‘0' => '审核拒绝', 
                        ‘1' => '审核通过', 
    		]),
    
         'value' => function($date) {
                        switch ($date-> status) {
                            case 1';
                                return '审核通过';
                                break;
                            case ‘0';
                                return '审核拒绝';
                                break;
                            default:
                                return '未知状态';
                                break;
                        }
                    }
                ],
    

    4.私人定制增删改按钮

    [
                    'header' => "查看/审核",
                    'class' => 'yiigridActionColumn',
                    'template'=> '{view} {update} {delete}',
                    'headerOptions' => ['width' => '140'],
                    'buttons' => [
                        'view' => function ($url, $model, $key) {
                            return Html::a(Html::tag('span', '', ['class' => "glyphicon fa fa-eye"]), ['admin/view-app', 'id'=>$model->app_id], ['class' => "btn btn-xs btn-success", 'title' => '查看']);
                        },
                        'update' => function ($url, $model, $key) use($uid){
                              return Html::a('通过', ['admin/reviewapp','id'=>$model->app_id, 'status’=>1], ['class' => "btn btn-xs btn-info"]);
                        },
                        'delete' => function ($url, $model, $key) {
                                return Html::a('拒绝', ['admin/reviewapp', 'id' => $model->app_id, 'status’=>0], ['class' => "btn btn-xs btn-danger"]);
                        }
                    ]
    ],
    
  • 相关阅读:
    Unity3d与Android交互
    A star 寻路
    网络协议
    数据驱动
    有限状态机(FSM)
    自己封装一个Log模块
    Unity5.x版本AssetBundle加载研究
    Unity5.x版本AssetBundle打包研究
    alidoing --使用JS实现多语言框架、喜欢的请进、、瓦特平台!
    使用代码生成器“代码工厂”快速生成B/S程序代码
  • 原文地址:https://www.cnblogs.com/GaoAnLee/p/5197773.html
Copyright © 2011-2022 走看看