<?php
+use kartik\export\ExportMenu;
use kartik\grid\ActionColumn;
use kartik\grid\GridView;
use kartik\grid\SerialColumn;
<h1><?= Html::encode($this->title) ?></h1>
+ <?php
+ $gridColumns = [
+ ['class' => SerialColumn::class],
+ 'id',
+ 'location',
+ 'name',
+ 'type_num',
+ 'category',
+ 'subcategory',
+ 'species',
+ 'sort',
+ 'type',
+ 'size',
+ 'measure',
+ 'color',
+ [
+ 'class' => ActionColumn::class,
+ 'header' => 'Действия',
+ 'template' => '{view}',
+ 'urlCreator' => function ($action, Products1cNomenclature $model, $key, $index, $column) {
+ return Url::toRoute([$action, 'id' => $model->id]);
+ }
+ ],
+ ];
+ $exportMenu = ExportMenu::widget([
+ 'dataProvider' => $dataProvider,
+ 'columns' => $gridColumns,
+ 'exportConfig' => [
+ ExportMenu::FORMAT_EXCEL => [
+ 'label' => 'Excel',
+ 'filename' => 'export_' . date('Y-m-d'),
+ ],
+ ],
+ 'dropdownOptions' => [
+ 'label' => 'Экспорт данных',
+ 'class' => 'btn btn-secondary',
+ ],
+ ]); ?>
+
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
- 'columns' => [
- ['class' => SerialColumn::class],
- 'id',
- 'location',
- 'name',
- 'type_num',
- 'category',
- 'subcategory',
- 'species',
- 'sort',
- 'type',
- 'size',
- 'measure',
- 'color',
- [
- 'class' => ActionColumn::class,
-
- 'template' => '{view}',
- 'urlCreator' => function ($action, Products1cNomenclature $model, $key, $index, $column) {
- return Url::toRoute([$action, 'id' => $model->id]);
- }
+ 'columns' => $gridColumns,
+ 'export' => [
+ 'label' => 'Экспорт',
+ 'header' => '<li role="presentation" class="dropdown-header">Экспорт страницы</li>',
+ 'fontAwesome' => false,
+ 'showConfirmAlert' => false,
+ 'target' => GridView::TARGET_BLANK,
+ ],
+ 'exportConfig' => [
+ GridView::EXCEL => [
+ 'label' => 'Excel',
+ 'icon' => 'file-excel',
+ 'filename' => 'export_' . date('Y-m-d'),
+ 'options' => ['title' => 'Сохранить в Excel'],
],
],
+ 'toolbar' => [
+ '{export}',
+ ],
+ 'panel' => [
+ 'type' => GridView::TYPE_SECONDARY,
+ 'heading' => '<h3 class="panel-title">Список товаров</h3>',
+ ],
]); ?>