Tlopasha Tlopasha - 7 days ago 6
PHP Question

GridView::FILTER_SELECT2 dont work

I try to use SELECT2 as a filter for a column but it didn't render!

This is my code :

<?php
use yii\helpers\Html;
use yii\widgets\LinkPager;
use yii\widgets\ListView;
use yii\data\ActiveDataProvider;
use kartik\grid\GridView;
use yii\widgets\Pjax;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\models\country;
?>
<?php
echo GridView::widget([
'columns' => [
['attribute' =>'id','filter'=>GridView::FILTER_SELECT2],
'name'],
'dataProvider'=> $dataProvider,
'filterModel' => $searchModel,
'export'=>false,
'pjax'=>true,
'pjaxSettings'=>[
'neverTimeout'=>true]

]);
?>


and than I get this result in browser:

photo

Answer

It should be filterType instead of filter.

['attribute' => 'id', 'filterType' => GridView::FILTER_SELECT2]
Comments