Hi, I’m new to Yii and I have installed the kartik export extension. When I click on export in any format, I get the following error:
File not found
Firefox can’t find the file at http://localhost/basic/web/index.php?r=industrial/index&page=1.
Check the file name for capitalization or other typing errors.
Check to see if the file was moved, renamed or deleted.
When I run this path mentioned, the page opens normally. Am I missing something here?
Please check my code:
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,
]);
}
}
Views/industrial/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,
]
]); ?>
What is the action I need to add to the controller to download the extracted file?