Hi i'm using yii2 Gridview and i have a filter dropdown option in my gridcolumn , while selecting the dropdown option my grid result changes correctly but i need to retain the selected dropdown option filter , see my code below,
$func = Model::get_rolename();
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchmodel,
'rowOptions' => function($model) {
return ['data-tt-id' => $model['UserId'], 'data-tt-parent-id' => $model['ManagerId']];
},
'options' => ['id' => 'sup_review'],
'columns' => [
[
'label' => 'First name',
'sortLinkOptions' => ['class' => 'desc'],
'format' => 'html',
'attribute' => 'FirstName',
'filterInputOptions' => [
'placeholder' => 'Search Name..',
'class' => 'form-control',
],
'value' => function ($model, $key, $index, $column) {
return $model['FirstName'];
},
],
[
'label' => 'Role test',
'sortLinkOptions' => ['class' => 'desc'],
'format' => 'ntext',
'attribute' => 'ClientId',
'filter' => $func,
'value' => function ($model, $key, $index, $column) {
return $model['RoleName'];
},
],
[
'label' => 'Actions',
'content' => function($model) use ($from, $to) {
return Html::a('<span class="btn btn-sm btn-primary">View</span>', Yii::$app->request->baseUrl . '/controller/function/?userid=' . $model['UserId'] . '&from=' . $from . '&to=' . $to, [
'title' => Yii::t('app', 'View'),
'data-pjax' => '0',
]);
}
],
],
]);
Thanks in advance :)