YII2 Kartik gridview disable pdf export
How to disable pdf export property in gridview in kartik?
I installed gridview kartik and it gave me the following error.
Class '\ kartik \ mpdf \ Pdf' not found and required for PDF export. To enable PDF export, follow the installation steps below. If you don't need PDF export functionality, do not include "PDF" as a format in the "export" property. Otherwise, you can set 'export' to false to disable all export functions.
Make sure you have installed the 'yii2-mpdf' extension. to install, you can run this console command from your application root:
php composer.phar requires kartik-v / yii2-mpdf: "@dev"
I don't want to install mpdf. I just want to turn it off. Where can I edit it?
source to share
You have to set the property export
to false
, it is even mentioned in the error text.
use kartik\grid\GridView;
...
<?= GridView::widget([
...
'export' => false,
]) ?>
More details in the official docs .
Update:
Another way to do this is to exclude PDF from exportConfig
.
<?= GridView::widget([
'exportConfig' => [
GridView::CSV => [
...
],
... // Make sure there is no GridView::PDF
],
]) ?>
source to share
If you are using both kartik\export\ExportMenu
, kartik\export\GridView
you must set the property exportConfig
for "PDF" false
to ExportMenu
and export
for the property false
in the GridView.
See below:
use kartik\grid\ExportMenu;
use kartik\grid\GridView;
<?= ExportMenu::widget([
...
'exportConfig' => [
ExportMenu::FORMAT_PDF => false,
],
]) ?>
<?= GridView::widget([
...
'export' => false,
]) ?>
source to share