我正在使用gridView :: FILTER_SELECT2,其中multiple = TRUE且AllowClear = TRUE。
问题1 :当我选择单个选项时,它可以正常工作,但是当我选择其他选项时,它会覆盖第一个选项并相应地进行过滤。
$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,
]); ?>
问题2 :当我尝试通过单击x删除所选选项时,它不会清除选择并抛出js错误。
TypeError: args is undefined --- args.prevented = true;