<?php
+use kartik\grid\GridView;
use kartik\select2\Select2;
use yii\bootstrap\ActiveForm;
-use yii\grid\GridView;
+use kartik\export\ExportMenu;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii_app\records\CityStore;
<?php ActiveForm::end() ?>
</div>
- <?= GridView::widget([
+ <?php
+ $columns = [
+ ['class' => 'yii\grid\SerialColumn'],
+ 'name',
+ 'articule',
+ 'id',
+ [
+ 'attribute' => 'is_valid',
+ 'label' => 'Активен ли букет на МП?',
+ 'value' => function ($model) {
+ return $model['is_valid'] ? 'Да' : 'Нет';
+ }
+ ],
+ [
+ 'attribute' => 'reason',
+ 'label' => 'Причина не активности',
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ return nl2br(htmlspecialchars($model['reason'] ?? ''));
+ },
+ ],
+ ];
+ $exportMenu = ExportMenu::widget([
+ 'container' => ['class' => 'btn-group mr-2 mt-2 mb-2'],
'dataProvider' => $dataProvider,
- 'columns' => [
- ['class' => 'yii\grid\SerialColumn'],
- 'name',
- 'articule',
- 'id',
- [
- 'attribute' => 'is_valid',
- 'label' => 'Активен ли букет на МП?',
- 'value' => function ($model) {
- return $model['is_valid'] ? 'Да' : 'Нет';
- }
- ],
- [
- 'attribute' => 'reason',
- 'label' => 'Причина не активности',
- 'format' => 'raw',
- 'value' => function ($model) {
- return nl2br(htmlspecialchars($model['reason'] ?? ''));
- },
+ 'columns' => $columns,
+ 'exportConfig' => [
+ ExportMenu::FORMAT_EXCEL => [
+ 'label' => 'Excel',
+ 'options' => ['title' => 'Сохранить в Excel'],
],
+ ExportMenu::FORMAT_TEXT => false,
+ ExportMenu::FORMAT_HTML => false,
+ ExportMenu::FORMAT_CSV => false,
+ ExportMenu::FORMAT_PDF => false,
+
],
+ 'filename' => 'export_' . date('Y-m-d'),
+ 'showColumnSelector' => false,
+ 'showConfirmAlert' => false,
+ 'target' => ExportMenu::TARGET_SELF,
+ 'dropdownOptions' => [
+ 'label' => 'Экспорт данных',
+ ],
+ ]);
+ echo $exportMenu;?>
+ <?= GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'columns' => $columns
]); ?>
</div>
\ No newline at end of file