0

I'm trying to use kartik gridview and got the following error. -

Undefined variable: gridColumns

I've checked - Yii2: Kartik Gridview sum of a column in footer. But didn't find the issue in my code.

Code of index.php -

<?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => $gridColumns,
        'showPageSummary' => true,
        'columns' => [
            ['class' => 'kartik\grid\SerialColumn'],
            [
                'attribute'=>'s_period',
                'filter'=>ArrayHelper::map(Salary::find()->asArray()->all(), 's_period', 's_period'),
            ],
            's_empid',
            's_empname',
            [
                'attribute'=>'s_epf',
                'pageSummary'=>true
            ],


            //['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
Community
  • 1
  • 1
Alias
  • 681
  • 16
  • 55

1 Answers1

1

if you assign manually the columns you don't need a var iwth columns specification so remove it

<?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        //'columns' => $gridColumns,
        'showPageSummary' => true,
        'columns' => [
            ['class' => 'kartik\grid\SerialColumn'],
            [
                'attribute'=>'s_period',
                'filter'=>ArrayHelper::map(Salary::find()->asArray()->all(), 's_period', 's_period'),
            ],
            's_empid',
            's_empname',
            [
                'attribute'=>'s_epf',
                'pageSummary'=>true
            ],


            //['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107