dounai9592
2017-12-05 06:17
采纳率: 100%
浏览 200
已采纳

YII2 Kartik - ExportMenu仅使用选中项目导出数据

I include Kartik yii2 ExportMenu plugin and its working fine for all data export but now I want to export only selected rows which is checked on grid.

<?php 
  $gridColumns = [
      ['class' => 'yii\grid\SerialColumn'],
      'username',
      'email',
      [
         'label' => Yii::t('app','User Access'),
         'value' => function($model){ 
              if($model->access_level == 1) { return 'Read/Write/Import/Export'; }
              if($model->access_level == 2) { return 'Read/Write'; }
              if($model->access_level == 3) { return 'Read'; }
            }
      ],
      'fullname',
      // [
      //    'label' => Yii::t('app','Status'),
      //    'value' => function($model){ 
      //         if($model->status == 10) { return 'Active'; }
      //         if($model->status == 0) { return 'Inactive'; }
      //       }
      // ],
      [
     'attribute' => 'created_at',
     'format' => ['date' , 'php:d/m/Y'],
     'label' => Yii::t('app','Created On'),
     'headerOptions' => ['style' => 'width:12%;'],
      ],
      [
         'attribute' => 'updated_at',
         'format' => ['date' , 'php:d/m/Y'],
         'label' => Yii::t('app','Modified On'),
         'headerOptions' => ['style' => 'width:12%;'],
      ],
      // 'updated_by',
      [
         'attribute' => 'updated_by',
         'label' => Yii::t('app','Modified By'),
         'headerOptions' => ['style' => 'width:12%;'],
        'value' => 'user.username',
        //  'value' => function($model){ 
        //       return $model->user->username;
        // }
      ],

      // ['class' => 'yii\grid\ActionColumn'],
  ]; 
      echo ExportMenu::widget([
               'dataProvider' => $dataProvider,
               'columns' => $gridColumns,
               'target' => ExportMenu::TARGET_BLANK,
               'showConfirmAlert' => false,
               'filename' => 'Users',
               'dropdownOptions' => [
                'label' => 'Export',
                'class' => 'btn btn-info', 
                'export' => true,
                'toolbar'=>[
                '{export}',
                '{toggleData}'
                ]          
              ],
               'exportConfig'=>[
               ExportMenu::FORMAT_HTML=>false,
               ExportMenu::FORMAT_TEXT=>false,
               ExportMenu::FORMAT_PDF=>false,
               ExportMenu::FORMAT_EXCEL=>false,
               ],
          ]);?>

Can anyone please help me to export data which is checked only . If you need any other information related code please ask. Thanks.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题