How to disable the pdf export property in kartik gridview?
如何禁用kartik gridview中的pdf导出属性?
I have installed the kartik gridview and it gave me the following error.
我已经安装了kartik gridview,它给了我以下错误。
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.
找不到类'\ kartik \ mpdf \ Pdf',这是PDF导出功能所必需的。要包含PDF导出,请按照下面的安装步骤操作。如果您不需要PDF导出功能,请不要在“export”属性中包含“PDF”作为格式。您可以将'export'设置为false以禁用所有导出功能。
Please ensure you have installed the 'yii2-mpdf' extension. To install, you can run this console command from your application root:
请确保您已安装'yii2-mpdf'扩展程序。要安装,您可以从应用程序根目录运行此控制台命令:
php composer.phar require kartik-v/yii2-mpdf: "@dev"
php composer.phar需要kartik -v / yii2-mpdf:“@ dev”
I do not want to installe the mpdf. Just want to disable it. Where can I edit it?
我不想安装mpdf。只是想禁用它。我在哪里可以编辑它?
2 个解决方案
#1
You should set export
property to false
, it's even mentioned in error text.
您应该将export属性设置为false,甚至在错误文本中提到它。
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
.
另一种方法是从exportConfig中排除PDF格式。
<?= GridView::widget([
'exportConfig' => [
GridView::CSV => [
...
],
... // Make sure there is no GridView::PDF
],
]) ?>
#2
If you are using both kartik\export\ExportMenu
& kartik\export\GridView
, you have to set exportConfig
property for 'PDF' to false
in ExportMenu
and export
property to false
in GridView.
如果同时使用kartik \ export \ ExportMenu和kartik \ export \ GridView,则必须在ExportMenu中将“PDF”的exportConfig属性设置为false,并在GridView中将属性导出为false。
See below:
use kartik\grid\ExportMenu;
use kartik\grid\GridView;
<?= ExportMenu::widget([
...
'exportConfig' => [
ExportMenu::FORMAT_PDF => false,
],
]) ?>
<?= GridView::widget([
...
'export' => false,
]) ?>
#1
You should set export
property to false
, it's even mentioned in error text.
您应该将export属性设置为false,甚至在错误文本中提到它。
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
.
另一种方法是从exportConfig中排除PDF格式。
<?= GridView::widget([
'exportConfig' => [
GridView::CSV => [
...
],
... // Make sure there is no GridView::PDF
],
]) ?>
#2
If you are using both kartik\export\ExportMenu
& kartik\export\GridView
, you have to set exportConfig
property for 'PDF' to false
in ExportMenu
and export
property to false
in GridView.
如果同时使用kartik \ export \ ExportMenu和kartik \ export \ GridView,则必须在ExportMenu中将“PDF”的exportConfig属性设置为false,并在GridView中将属性导出为false。
See below:
use kartik\grid\ExportMenu;
use kartik\grid\GridView;
<?= ExportMenu::widget([
...
'exportConfig' => [
ExportMenu::FORMAT_PDF => false,
],
]) ?>
<?= GridView::widget([
...
'export' => false,
]) ?>