我正在尝试使用kartik导出它不适合我。在配置文件中,我添加了以下代码:
'modules' => [
'gridview' => [
'class' => '\kartik\grid\Module',
],
],
在Composer中,我添加了以下代码
"kartik-v/yii2-export": "@dev",
"kartik-v/yii2-mpdf":"@dev",
"kartik-v/yii2-grid": "@dev"
我的观看代码是这样的:
<?php
use yii\helpers\Html;
use kartik\grid\GridView;
use yii\bootstrap\Tabs;
use kartik\export\ExportMenu;
use yii\widgets\Pjax;
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="general-info-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php
<p>
<?= Html::a('create', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?php
$gridColumns = [
'sfcl_name',
[
'attribute'=> 'org_type',
'value' => 'orgType.cv_lbl'
],
];
echo ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns
]);
?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'pjax'=>true,
'columns' => [
'sfcl_name',
'phone',
[
'attribute'=>'regd_dt_ad',
'format'=>['date', 'php:Y-M-d'],
'xlFormat'=>'mmm\-dd\, yyyy', // different date format
'width'=>'100px'
],
[
'attribute'=> 'org_type',
'value' => 'orgType.cv_lbl'
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>
我的控制器代码是:
My controller code to call this view : public function actionIndex()
{
$searchModel = new SfclGeneralSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
点击导出菜单没有任何事情发生。在教程中,我看到有导出到pdf,html,csv,json,text的选项。这样的选项不会出现在我的情况下。是css不工作还是什么?
答案 0 :(得分:0)
你跑'#34;作曲家更新&#34;命令?
也在你的web.php
中'modules' => [
'gridview' => [
'class' => '\kartik\grid\Module',
],
],
添加属性downloadAction,如下所示:
'modules' => [
'gridview' => [
'class' => '\kartik\grid\Module',
'downloadAction' => 'gridview/export/download',
]
],