Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YII2 Kartik gridview disable pdf export

Tags:

yii2

How to disable the pdf export property in kartik gridview?

I have installed the kartik gridview and it gave me the following error.

The class '\kartik\mpdf\Pdf' was not found and is required for PDF export functionality. To include PDF export, follow the install steps below. If you do not need PDF export functionality, do not include 'PDF' as a format in the 'export' property. You can otherwise set 'export' to false to disable all export functionality.

Please ensure you have installed the 'yii2-mpdf' extension. To install, you can run this console command from your application root:

php composer.phar require kartik-v/yii2-mpdf: "@dev"

I do not want to installe the mpdf. Just want to disable it. Where can I edit it?

like image 539
beginner Avatar asked Feb 11 '23 04:02

beginner


1 Answers

You should set export property to false, it's even mentioned in error text.

use kartik\grid\GridView;

...

<?= GridView::widget([
    ...
    'export' => false,
]) ?>

Read more in official docs.

Update:

Another way to do that is exclude PDF format from exportConfig.

<?= GridView::widget([
    'exportConfig' => [
        GridView::CSV => [
            ...
        ],
        ... // Make sure there is no GridView::PDF
    ],
]) ?>
like image 198
arogachev Avatar answered Feb 26 '23 16:02

arogachev