Problem With Dropdown Filter.

I have a dropDown filter in a grid view like this:




'filter'=> CHtml::listdata(Products::model()->findAll(), 'id', 'name'),



It works fine when I pick an option. But if I search first on a normal input field, then it doesn’t work. Nothing is sent via AJAX, but if I change to another options it starts working again. So it fails only after searching on a normal field.

Any ideas on how to solve it? I’ve been looking around but I didn’t find anything.

wrap it in a activeDropDownList like so


'filter'=>CHtml::activeDropDownList($model, 'name', CHtml::listdata(Products::model()->findAll(), 'id', 'name'))

Nothing changes. I got the same problem.

you have to change the foreign id


'filter'=>CHtml::activeDropDownList($model, 'foreign_key_goes_here', CHtml::listdata(Products::model()->findAll(), 'id', 'name'));

I’m still having this issue all over my applications. No matter how I create the array for the filter. It doesn’t work after a normal search, only if you change it twice.

I think its a browser specific problem. There’s a github issue related to it by the way:

Basically the problem is when you hit ENTER for a textbox search, a "keydown" event is triggered and also sets the variable eventType to "keydown". Selecting a dropdown filter value afterwards would trigger a "change" event, but because eventType is set to "keydown", the function stops processing there. The reason it works the second time is because it empties out the eventType variable before it stops.