Closed shum16 closed 6 years ago
I wonder if nobody uses Select2 as a multifilter...
@shum16 I have the same issue, after clearing the last item, it remains there.
up!
i have the same issue, please help us!
no fix or workaround for this issue? thanks
Will need to check on this...
Set allowClear
to true
and then use the main CLEAR cross button to clear all selected items in the multi select.
Kartik, this solution doesn't work!
Even for me dosent work. At the moment i have resolved moving the search fields outside the gridview like this work like a sharm.
Il 15/ago/2016 14:19, "shum16" notifications@github.com ha scritto:
Kartik, this solution doesn't work!
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kartik-v/yii2-widget-select2/issues/145#issuecomment-239788916, or mute the thread https://github.com/notifications/unsubscribe-auth/AOVz3JiQ7sVQqFv00QIg6ozJZv8Raeucks5qgFlVgaJpZM4INg45 .
Kartik, any news on this issue?
Will need to study this. Unfortunately it seems this is out of scope of both the Select2 widget as well as this extension... but more to do with how you load search model using mass assignment and write your search method to filter grid rows. There needs to be some way you can trap the last unselected data.
Will check back to see if there is something that can be done here when I get some time.
@kartik-v , ok, thank you.
@kartik-v any news on this issue?
i have the same problem, @kartik-v can you help?
this issue still not resolved? i have start a new project and still have the problem. thanks
Whether is understanding when it is possible to wait for a fix of this problem? thanks.
I have this issue also.. Somebody know how to fix this?
$("#select2_id").select2("val", ""); does not work too...
PS It seems that this is a bug in yii2.. I tried other multi-select widgets and they have the same problem.
Update, I found solution: you need set 'filterUrl' => Url::to(["/your-grid-view-url"]), (in GridView)
Kartik, help us please, we need go on developing. Fix this bug, please
Not sure this is an issue any more. It depends on how you are configuring this.
Check the updated grid demo - the author is a multi select filter and seems to work like a charm. Go through the demo config and let know if any issues.
@kartik-v hi, same issue, what's the solution? Anyone can help me
Working example. One column:
[
'attribute' => 'status_id',
'label' => 'Статус',
'enableSorting' => true,
'filter' => Select2::widget([
'name' => 'status',
'pjaxContainerId' => $pjaxContainer,
'value' => $_GET['status'] ?? '',
'data' => $statuses,
'size' => Select2::SMALL,
'options' => [
'multiple' => true,
'placeholder' => Yii::t('admin', 'Не указан')
],
'pluginOptions' => [
'allowClear' => true,
'required' => true
]
]),
'content' => function ($model) {
.....
return $str;
}
return $model->status ? $model->status->name : '';
},
'headerOptions' => ['style' => 'text-align:center;width:120px;']
]
I got it to work by adding a hidden input with the same name right before the select2, eg:
$columns[] = [
'attribute' => 'status',
'filter' => Html::hiddenInput('CompanySearch[status]')
. Select2::widget([
'name' => 'CompanySearch[status]',
'value' => $searchModel->status,
'data' => $data,
'options' => [
'multiple' => true,
],
]),
]
As mentioned before - check the updated grid demo - the author is a multi select filter and seems to work like a charm. Go through the demo config and let know if any issues.
I got it to work by adding a hidden input with the same name right before the select2, eg:
$columns[] = [ 'attribute' => 'status', 'filter' => Html::hiddenInput('CompanySearch[status]') . Select2::widget([ 'name' => 'CompanySearch[status]', 'value' => $searchModel->status, 'data' => $data, 'options' => [ 'multiple' => true, ], ]), ]
this working, tky.
I'm using Select2 as a multiple GridView filter. And it works fine afterall, except for one thing: it's not possible to remove the last selected item from the list. Every time I try to do that, it reloads the grid with the same item in the filter, - becasue the value comes again with $_GET array!
Here's how it looks like:
Here's the column definition: