我正在渲染一个Kartik's Gridview,它通过ExpandRowColumn小部件的ajax加载另一个Gridview。
我想使用网格工具导出这个二级加载网格,但是当我启用导出菜单并尝试导出它时,它将下载主网格而不是第二个网格。甚至我在第二个网格上设置的导出配置选项也没有考虑在内。我尝试为第二个网格设置自定义id
,但没有改变任何内容。
这是第一个网格:
```
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => false,
'columns' => [
[
'class' => 'kartik\grid\ExpandRowColumn',
'value' => function ($model, $key, $index) {
return GridView::ROW_COLLAPSED;
},
'detailUrl' => Url::to(['ajax-riepilogo', 'idf' => $f]),
],
'descrizione',
],
]);
```
这是ajax-riepilogo
中生成的那个:
```
GridView::widget([
'dataProvider' => $secondDataProvider,
'id' => 'grid-riepilogo',
'panel' => [
'type' => 'primary',
'heading' => false,
],
'toolbar' => ['{export}'],
'export' => [
'showConfirmAlert' => false,
'target' => GridView::TARGET_BLANK,
'exportConfig' => [
GridView::CSV => [
'filename' => "riepilogo',
],
GridView::EXCEL => [
'filename' => "riepilogo',
],
],
],
'summary' => false,
'filterModel' => false,
'columns' => [
...
```
答案 0 :(得分:0)
两个错误:
id
对于页面中的每个网格必须是唯一的exportConfig
配置属性需要位于顶级 工作配置:
GridView::widget([
'dataProvider' => $secondDataProvider,
'id' => 'grid-riepilogo-'.$unique,
'panel' => [
'type' => 'primary',
'heading' => false,
],
'toolbar' => ['{export}'],
'export' => [
'showConfirmAlert' => false,
'target' => GridView::TARGET_BLANK,
],
'exportConfig' => [
GridView::CSV => [
'filename' => "riepilogo',
],
GridView::EXCEL => [
'filename' => "riepilogo',
],
],
'summary' => false,
'filterModel' => false,
'columns' => [
...