beginner
beginner

Reputation: 2032

YII2 export menu on kartik gridview not showing

I have installed the kartik gridview and from the documentation and demo, I copied some of the codes and got this one..

<?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'hover'=>true,
        'condensed'=>true,
        'floatHeader'=>true,
        'bordered'=>true,
        'pjax' => true,
        'toolbar'=>[
                    '{export}',
                    '{toggleData}',
                    ],
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            [
                'attribute'=>'province',
                'label'=>'Province',
                'value'=>'cityCode.provCode.prov_name',
            ],....

The page displays well the gridview but the export button is missing. Do I still need to download the export plugins? Or do the code lacks of important configurations??

Upvotes: 2

Views: 4982

Answers (2)

Kalaiselvan Mahendiran
Kalaiselvan Mahendiran

Reputation: 996

Try this i hope this will Help you, Just copy and paste it, then replace fields alone with your fields thats it.

use kartik\export\ExportMenu;

<?php $gridColumns = [
    ['class' => 'yii\grid\SerialColumn'],
        'companyname',
        'companyaddress:ntext',
        'hrname',
        'email:email',
        'mobile',
        'typeofcompany',
        'companytype',
        'relationoption',
        'relation',
    ['class' => 'yii\grid\ActionColumn'],
    ]; ?>

<?= ExportMenu::widget([
        'dataProvider' => $dataProvider,
        'columns' => $gridColumns,
        'columnSelectorOptions'=>[
            'label' => 'Columns',
            'class' => 'btn btn-danger'
        ],
        'fontAwesome' => true,
        'dropdownOptions' => [
            'label' => 'Export All',
            'class' => 'btn btn-success'
        ]
    ]); ?>

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => $gridColumns,
]); ?>

Upvotes: 5

Mohan Rex
Mohan Rex

Reputation: 1674

You just need to add the panel heading in your grid view or you should add the export button where ever you want in that grid view

'panel' => [
    'heading'=>'<h3 class="panel-title"><i class="glyphicon glyphicon-globe"></i> '. Html::encode($this->title).'</h3>',
    'type'=>'primary',
    'before'=>Html::a('<i class="glyphicon glyphicon-plus"></i>New Registration', ['create'], ['class' => 'btn btn-primary']),
    'showFooter'=>false
],

Upvotes: 3

Related Questions