yii2-girdView的使用(1)——数据导出

以下为个人常用代码块记录:

	<?php
	use yii\helpers\Html;
    use kartik\grid\GridView;//注意引用的类
    ?>
    <?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
        'vow_name',
     ]
     //--------------------------------导出使用的代码块------------------------------------------------
    'toolbar' => [
        ['content' =>
            Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['index'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => '刷新']),
        ],
        '{export}',
        '{toggleData}'
    ],
    'exportConfig'=> [
        GridView::EXCEL => ['filename' =>'许愿记录'],//导出excel,要导出其他格式
        //可用  GridView::EXCEL以外的
    ],
    'bordered' => true,
    'striped' => false,
    'condensed' => false,
    'hover' => true,
    'panel' => [
        'type' => GridView::TYPE_DEFAULT
    ]
    //---------------------------------导出使用的代码块-------------------------------------------------
]); ?>

详情请看官方文档

发布了12 篇原创文章 · 获赞 4 · 访问量 4345

猜你喜欢

转载自blog.csdn.net/u013083541/article/details/87280684