我通过演示阅读并应用了他们所说的一切。到目前为止我的代码工作正常没有错误。但是当我从下拉菜单中点击pdf下载后,就会发生这种情况 取消阻止弹出窗口。我解锁了它。 然后打开一个带有文本的新窗口"生成pdf以导出" 但它没有做任何事情。它就像一个关于:空白页面。我错过了什么它完美地适用于现场演示。
的index.php
$gridColumns = [
['class' => 'kartik\grid\SerialColumn'],
'id',
'title',
['class' => 'kartik\grid\ActionColumn'],
];
echo ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'target'=>ExportMenu::TARGET_POPUP,
]);
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'id' => 'w2',
//'pjax' => true,
'columns' => [
['class' => 'kartik\grid\CheckboxColumn'],
'user_id',
[ ...
以下是用途:
use yii\helpers\Html;
//use yii\grid\GridView;
use common\models\user\AbstractsSearch;
use yii\widgets\ActiveForm;
use backend\models\AssignedAbstracts;
use kartik\grid\GridView;
use common\models\Board;
use common\models\user\User;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use yii\widgets\Pjax;
use kartik\export\ExportMenu;
以下是我$dataProvider
object(yii\data\ActiveDataProvider)[32]
public 'query' =>
object(yii\db\ActiveQuery)[34]
public 'sql' => null
public 'on' => null
public 'joinWith' => null
public 'select' => null
public 'selectOption' => null
public 'distinct' => null
public 'from' => null
public 'groupBy' => null
public 'join' => null
public 'having' => null
public 'union' => null
public 'params' =>
array (size=0)
empty
private '_events' (yii\base\Component) =>
array (size=0)
empty
private '_behaviors' (yii\base\Component) =>
array (size=0)
empty
public 'where' =>
array (size=1)
'conferenceId' => int 2
public 'limit' => null
public 'offset' => null
public 'orderBy' => null
public 'indexBy' => null
public 'modelClass' => string 'common\models\user\Abstracts' (length=28)
public 'with' => null
public 'asArray' => null
public 'multiple' => null
public 'primaryModel' => null
public 'link' => null
public 'via' => null
public 'inverseOf' => null
public 'key' => null
public 'db' => null
public 'id' => null
private '_sort' (yii\data\BaseDataProvider) => null
private '_pagination' (yii\data\BaseDataProvider) =>
object(yii\data\Pagination)[131]
public 'pageParam' => string 'page' (length=4)
public 'pageSizeParam' => string 'per-page' (length=8)
public 'forcePageParam' => boolean true
public 'route' => null
public 'params' => null
public 'urlManager' => null
public 'validatePage' => boolean true
public 'totalCount' => int 0
public 'defaultPageSize' => int 20
public 'pageSizeLimit' =>
array (size=2)
0 => int 1
1 => int 50
private '_pageSize' => int 2000
private '_page' => null
private '_keys' (yii\data\BaseDataProvider) => null
private '_models' (yii\data\BaseDataProvider) => null
private '_totalCount' (yii\data\BaseDataProvider) => null
private '_events' (yii\base\Component) =>
array (size=0)
empty
private '_behaviors' (yii\base\Component) => null
答案 0 :(得分:2)
我将以下代码放在一个阻止提交请求的活动表单中
$gridColumns = [
['class' => 'kartik\grid\SerialColumn'],
'id',
'title',
['class' => 'kartik\grid\ActionColumn'],
];
echo ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'target'=>ExportMenu::TARGET_POPUP,
]);
我尽快将代码放在活动表格旁边,下载开始没有任何延迟。
需要考虑的一些要点:
1)如果您没有使用活动表格并且您完成了我所做的工作,请清理浏览器缓存。
2)确保您的服务器允许下载pdf文件(大小(对于其他文件),输入)
3)交叉检查演示是否正在下载文件,并且您无法在本地主机或您的实际站点上下载,您的服务器肯定会阻止下载。
4)如果演示不适合你,则问题在于浏览器而不是代码或服务器。
如果存在任何其他问题,请转到链接并阅读讨论。它非常有帮助 Kartik's discussion on export file issues
答案 1 :(得分:0)
在我使用的工作软件中(所以没有弹出窗口的问题)
'target' => ExportMenu::TARGET_BLANK,
而不是
'target'=>ExportMenu::TARGET_POPUP,
我发现你正在使用
$gridColumns = [
['class' => 'kartik\grid\SerialColumn'],
'id',
'title',
['class' => 'kartik\grid\ActionColumn'],
['class' => 'kartik\grid\SerialColumn'],
和['class' => 'kartik\grid\ActionColumn'],
导出菜单不需要它们,可能会导致问题。删除它们或指定没有变量的列。