yii2如何在pjax中使用response sendFile()

问题描述 投票:0回答:1

我观察到,当我执行函数时:

[Yii::$app->request->sendFile()在带有gridView的一行中,而不是启动文件,而是显示它嵌入在HTML中。

然后如果我删除包围GridView的Pjax::begin()Pjax::end()边框,则可以下载。

我如何使用这两种功能而不丢失其中之一?

yii2 response sendfile
1个回答
0
投票

Yii2对此进行了讨论,目前的解决方案是使用此方法:

<?php Pjax::begin([
    'id' => 'list',
    'linkSelector' => '#list a:not([data-pjax=0])'
 ]); ?>
<a href="#" id="customListener" data-pjax="0">custom js or simple link to your action with download</a>
<a href="some/link">pjax link</a>
<?php Pjax::end(); ?>

看来此功能可能会包含在将来的版本中。

© www.soinside.com 2019 - 2024. All rights reserved.