[gridView] -- index页面重写

lulucms post模块index页面源代码



<?php

use yii\helpers\Html;
use source\core\grid\GridView;
use source\LuLu;
use source\models\Content;
use source\libs\Constants;

/* @var $this yii\web\View */
/* @var $searchModel app\models\search\ContentSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$type='post';
$this->title = '文章管理';
$this->params['breadcrumbs'][] = $this->title;


?>

<?php $this->toolbars([
    Html::a('新建11', ['create'], ['class' => 'btn btn-xs btn-primary mod-site-save']),
    Html::a('设置', ['setting/index'], ['class' => 'btn btn-xs btn-primary mod-site-save'])
]);?>

     
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        //'filterModel' => $searchModel,
        //设置布局
        'layout' => "{items}\n{pager}",
        'columns' => [
          
            [
                'class'=>'source\core\grid\IdColumn',
            ],
    		
            [
                'attribute'=>'title',
                'headerOptions'=>['width'=>'auto'],//headerOptions可以设置表格标题html属性.如with height等,如果修改内容是contentOptions属性
            ],
          
            [
                'class'=>'source\core\grid\DateTimeColumn',
                'attribute' => 'updated_at',
            ],
            //'allow_comment',
            //'comments',
    		'userText',
            'comment_count',
    		'view_count',
            [
                'attribute'=>'status',
                'width'=>'25px',
                'content'=>function($model,$key,$index,$gridView){
                    return Constants::getStatusItemsForContent($model->status);
                },
            ],
            // 'diggs',
            // 'burys',
            // 'sticky',
            // 'password',
            // 'visibility',
            //'status',
            // 'thumb',
            // 
            // 'alias',
            // 'excerpt',
            // 'content:ntext',
            // 'content_type',
            // 'template',

            ['class' => 'source\core\grid\ActionColumn'],
        ],
    ]); ?>                
             
           


IdColumn源代码

<?php
namespace source\core\grid;

class IdColumn extends DataColumn
{
    public $attribute='id';
    public $headerOptions=['width'=>'25px'];//设置id列宽度
    //public $contentOptions=['width'=>'25000px'];

    public function init()
    {
        parent::init();
    }
}


DataColumn源代码

<?php
namespace source\core\grid;

class DataColumn extends \yii\grid\DataColumn
{

    public $headerOptions = [];

    public $width = '60px';

    public function init()
    {
        parent::init();
        
        if (! isset($this->headerOptions['width']))
        {
            $this->headerOptions['width'] = $this->width;
        }
        $this->contentOptions=['style'=>'word-wrap: break-word; word-break: break-all;'];
    }
}

DateTimeColumn源代码

<?php
namespace source\core\grid;

class DateTimeColumn extends DataColumn
{
    public $headerOptions=['width'=>'120px'];//这个是设置index time列宽度
    
    public $format =['datetime', 'php:Y-m-d H:m:s'];

    public function init()
    {
        parent::init();
    }
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值