New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CGridView sometimes ignores filter change after ajax update #2881
Comments
I can't solve with this solution, shows "event is undefined" in console. |
Hi, I had the very same problem with firefox. The problem comes from the keyCode property which is not used by all browsers. On firefox it will return 0 for most of the key. (see http://unixpapa.com/js/key.html) A quick solution si to use something like : event.keyCode ? event.keyCode : event.charCode; So I modified the jquery.yiigridview.js to something like this : $(document).on('change.yiiGridView keydown.yiiGridView', settings.filterSelector, function (event) {
if (event.type === 'keydown') {
if ((event.keyCode ? event.keyCode : event.charCode) !== 13) {
return; // only react to enter key
} else {
eventType = 'keydown';
}
} else {
// prevent processing for both keydown and change events
if (eventType === 'keydown') {
eventType = '';
return;
}
} |
This issue still exists and I just encountered it today. When adding extra fields to |
@spacefrog your solution partially works, only function when the text field loses the focus if i press ENTER the grid does not update. My solution was initialize eventType to an empty string. Something like this: $(document).on('change.yiiGridView keydown.yiiGridView', settings.filterSelector, function (event) {
eventType = '';
if (event.type === 'keydown') {
if ((event.keyCode ? event.keyCode : event.charCode) !== 13) {
return; // only react to enter key
} else {
eventType = 'keydown';
}
} else {
// prevent processing for both keydown and change events
if (eventType === 'keydown') {
eventType = '';
return;
}
}
} |
My personal solution involved staying away from the source file (yiiGridView.js) and exporting the gridview's Here's a very abridged snippet filterSelector = $grid.data('filter');
payload = $(filterSelector).serialize();
$grid.yiiGridView('update', {data: payload}); |
I have tested the patch created by sivir in their tree and works fine for me. This issue happens in Firefox 30, but not in Chrome 35 and MS IE 11, so it's partially a browser specific issue. The patch works for all browsers mentioned above (confirmed). Will this be merged for version 1.1.16? |
It happens when CGridView has both text field and dropdown filters.
So eventType must be reset after each grid ajax update.
My solution:
The text was updated successfully, but these errors were encountered: