我是Yii
的新手,我已经安装了Kartik导出扩展程序。当我以任何格式点击导出时,我收到以下错误:
找不到文件
Firefox无法找到该文件 http://localhost/basic/web/index.php?r=industrial/index&page=1
检查文件名是否有大写或其他输入错误。校验 查看文件是否已移动,重命名或删除。
当我提到这条路径时,页面会正常打开。我在这里错过了什么吗?
请检查我的代码:
IndustrialController.php:
<?php
namespace app\controllers;
use yii\web\Controller;
use yii\data\Pagination;
use app\models\industrial;
use yii\data\ActiveDataProvider; class IndustrialController extends Controller {
public function actionIndex()
{
$query = industrial::find();
$pagination = new Pagination([
'defaultPageSize' => 20,
'totalCount' => $query->count(),
]);
$industrials = $query->orderBy('Company_Name')
->offset($pagination->offset)
->limit($pagination->limit)
->all();
$dataProvider=new ActiveDataProvider([
'query' => industrial::find(),
'pagination'=>['pageSize'=>20],
]);
//return $this->render('index', ['dataProvider'=>$dataProvider]);
return $this->render('index', [
'dataProvider'=>$dataProvider,
'industrials' => $industrials,
'pagination' => $pagination,
]);
}
}
查看/工业/ index.php的:
<?php
use yii\helpers\Html;
use kartik\export\ExportMenu;
use kartik\grid\GridView;
use yii\widgets\LinkPager;
$gridColumns = [ ['class' => 'yii\grid\SerialColumn'],
'Company_Name',
'Category',
'Phone',
'EMail',
];
?>
<?= ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'fontAwesome' => true,
'dropdownOptions' => [
'label' => 'Export All',
'class' => 'btn btn-default'
]
]) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'export' => [
'fontAwesome' => true,
]
]); ?>
我需要添加到控制器以下载提取的文件的操作是什么?