1
votes

I am using gridView::FILTER_SELECT2 with multiple = TRUE and AllowClear = TRUE.

Problem 1: When I select single option it works fine but when I select another option it overwrites the first option and filter accordingly.

$gridColumns[] = [
            'attribute'=>'clubName',
            'headerOptions'=>[
                'style'=>'width: 15%'
            ],

            'filterType'=>GridView::FILTER_SELECT2,
            'filter'=>Clubs::getClubs(),
            'filterWidgetOptions'=>[
            'pluginOptions'=>['allowClear'=>true,
                'tags' => true,
                'tokenSeparators' => [',', ' '],
                'maximumInputLength' => 10
                ],
            'options'=>['id' => 'unique-select2-id'],


            ],
            'filterInputOptions'=>['placeholder'=>'Select Club'],
            'value' => function($model, $key, $index, $column){
                    return urldecode($model->header->club->name);
                },

        ];
<?= GridView::widget([
            'headerRowOptions'=>['class'=>'kartik-sheet-style'],
            'dataProvider' => $dataProvider,
            'filterModel' => $searchModel,
            'pjax' => true,
            'responsive' => true,
            'pjaxSettings' => [
                'options' => [
                    'enablePushState' => false,
                    'options' => ['id' => 'unique-pjax-id'] // UNIQUE PJAX CONTAINER ID
                ],

            ],
            'columns' => $gridColumns,

            'panel'=>[
                'type'=>GridView::TYPE_PRIMARY,
                'heading'=>$this->title,
            ],

            // set your toolbar
            'toolbar'=> [
                ['content'=>''

                ],
                '{export}','{toggleData}'

            ],
// set export properties
'export'=>[
            'fontAwesome'=>true
        ],

            'showPageSummary'=> true,
        ]); ?>

Problem2: When I try to remove selected option by clicking x , it doesn't clear the selection and throwing js error.

TypeError: args is undefined --- args.prevented = true;
1
You might want to add some code here, doubtful that anyone will be able to help you with that little information. People can't see your screen and have no idea what you are talking about, so add as much (useful) information as you can. - Blizz

1 Answers

0
votes

It looks like there is a related issue in yii2 tracker https://github.com/yiisoft/yii2/issues/4431