1
votes

I want to add a DropDownList to the GridView, I did it in Filters include on GridView like that:

enter image description here

but I want to do it outside GridView like that

enter image description here

please someone help me!!!

2

2 Answers

1
votes

have a look at kartik/gridview

<?=
    GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'toolbar' => [
            ['content' =>
                Html::dropDownList('name', 'null', ['1' => 'Bulan ini', '2' => 'Bulan Lepas', '3' => 'Tahun ini', '4' => 'Tahun Lepas'], ['id' => 'gs1', 'class' => 'form-control'])
            ],
            '{export}',
            '{toggleData}',
        ],
        'panel' => [
            'type' => GridView::TYPE_PRIMARY,
            'heading' => $this->title,
        ],
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'ID',
            .....,
        ],
    ]);
    ?>
0
votes

have a look at kartik/gridview

<?=
    GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'toolbar' => [
            ['content' =>
                Html::dropDownList('name', 'null', ['1' => 'Bulan ini', '2' => 'Bulan Lepas', '3' => 'Tahun ini', '4' => 'Tahun Lepas'], ['id' => 'gs1', 'class' => 'form-control'])
            ],
            '{export}',
            '{toggleData}',
        ],
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'ID',
            .....,
        ],
    ]);
    ?>