Tuesday, November 18, 2014

Yii2 kartik GridView toolbar not showing up?

Took me some time, but I finally found out why.
If you're having problems with the toolbar in kartik\grid\GridView you probably haven't set the before property for the panel. Try this code see if it helps. Don't forget to replace the columns with your own.


<?= GridView::widget([
    'dataProvider'=> $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        'id',
        'email:email',
    ],
    'toolbar' => [
        ['content'=>
            Html::a('Add', ['create'], ['data-pjax' => 'false', 'class' => 'btn btn-success']) .
            Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['index'], ['data-pjax' => false, 'class' => 'btn btn-default', 'title'=>'Reset Grid'])
        ],
        '{export}',
        '{toggleData}'
    ],
    'panel' => [
        'heading' => '<b>My View</b>',
        'before' => 'Before content', //IMPORTANT
    ],
]);?>

1 comment: