pjax 阻止在 Controller 中使用 $app->response->sendFile
pjax prevents using $app->response->sendFile in Controller
以下代码
$completePath = Yii::getAlias('@pictures' . '/' . $filename);
return Yii::$app->response->sendFile($completePath, $filename);
如果我在没有 pjax 的情况下编写 GridView 代码,它将完成它的工作。如果我这样使用 pjax:
<?=
GridView::widget([
'dataProvider' => $dataProvider_vermieten,
'filterModel' => $searchModel,
'columns' => $gridColumn_vermieten,
'pjax' => true, //this code prevents rendering pdf
'pjaxSettings' => ['options' => ['id' => 'kv-pjax-container-immobilien']],
'panel' => [
'type' => GridView::TYPE_PRIMARY,
'before' => Html::a('<i class="glyphicon glyphicon-plus"></i> zur Hauptseite', ['/site/index'], ['class' => 'btn btn-info']),
'after' => Html::a('<i class="glyphicon glyphicon-repeat"></i> Reset Grid', ['/immobilien/index'], ['class' => 'btn btn-primary', 'title' => 'Setzt die GridView zurück']),
'heading' => '<span class="glyphicon glyphicon-book"></span> ' . Html::encode($this->title),
],
// your toolbar can include the additional full export menu
'toolbar' => [
['content' =>
Html::a('<i class="fa fa-folder-open"></i>', ['/immobilien/index', 'bez' => 'umbenennen'], ['class' => 'btn btn-primary', 'title' => 'additional content'])
],
'{export}',
'{toggleData}'
],
'toggleDataOptions' => ['minCount' => 10],
]);
?>
pdf 文件将不会呈现。任何想法,如何使用 pjax 渲染 pdf 文件?
我自己得到的:
以下代码也将使用 pjax 完成其工作:
return Html::a('<span class="glyphicon glyphicon-file"></span>', ['/immobilien/show', 'filename' => $filename], ['title' => 'Dokument anzeigen', 'data' => ['pjax' => '0']]);
以下代码
$completePath = Yii::getAlias('@pictures' . '/' . $filename);
return Yii::$app->response->sendFile($completePath, $filename);
如果我在没有 pjax 的情况下编写 GridView 代码,它将完成它的工作。如果我这样使用 pjax:
<?=
GridView::widget([
'dataProvider' => $dataProvider_vermieten,
'filterModel' => $searchModel,
'columns' => $gridColumn_vermieten,
'pjax' => true, //this code prevents rendering pdf
'pjaxSettings' => ['options' => ['id' => 'kv-pjax-container-immobilien']],
'panel' => [
'type' => GridView::TYPE_PRIMARY,
'before' => Html::a('<i class="glyphicon glyphicon-plus"></i> zur Hauptseite', ['/site/index'], ['class' => 'btn btn-info']),
'after' => Html::a('<i class="glyphicon glyphicon-repeat"></i> Reset Grid', ['/immobilien/index'], ['class' => 'btn btn-primary', 'title' => 'Setzt die GridView zurück']),
'heading' => '<span class="glyphicon glyphicon-book"></span> ' . Html::encode($this->title),
],
// your toolbar can include the additional full export menu
'toolbar' => [
['content' =>
Html::a('<i class="fa fa-folder-open"></i>', ['/immobilien/index', 'bez' => 'umbenennen'], ['class' => 'btn btn-primary', 'title' => 'additional content'])
],
'{export}',
'{toggleData}'
],
'toggleDataOptions' => ['minCount' => 10],
]);
?>
pdf 文件将不会呈现。任何想法,如何使用 pjax 渲染 pdf 文件?
我自己得到的: 以下代码也将使用 pjax 完成其工作:
return Html::a('<span class="glyphicon glyphicon-file"></span>', ['/immobilien/show', 'filename' => $filename], ['title' => 'Dokument anzeigen', 'data' => ['pjax' => '0']]);