Success! Looks like we've fixed this one. According to our records the fix was applied for
EXTJS-19699
in
5.1.3.228.
-
Remote proxy does not send store filters whose value is falsy
Affected versions:
ExtJS 5.1.2
(previous versions worked, ExtJS 6 seems to be unaffected)
Description:
When adding a store filter whose value is falsy (undefined, false, 0, null, NaN or "") no corresponding filter parameter is sent to the server by the proxy.
Expected behaviour:
The filter is sent to the server at least in cases where the filter value is false or 0.
Test case:
See this Fiddle https://fiddle.sencha.com/#fiddle/103n
-
Sencha - Support Team
Thanks for the report! I have opened a bug in our bug tracker.
-
Since 5.1.3 is not out yet, I publish this override fix here
Code:
/**
* This fixes a bug that was introduced wiht ExtJS 5.1.2 (but fixed in 5.1.3) whereby falsy filter values are not send
* to a remote server.
*
* For details refer to
* https://www.sencha.com/forum/showthread.php?306266-Remote-proxy-does-not-send-store-filters-whose-value-is-falsy
*
* @author: Sencha (+ fix by Pat Mächler, IWF web solutions)
* @license: Sencha Software License Agreement (https://www.sencha.com/legal/sencha-software-license-agreement/)
*/
Ext.define('App.overrides.data.proxy.AllowFalsyRemoteFilterValues', {
override: 'Ext.data.proxy.Server',
//5.1.2
compatibility : ['5.1.2.748'],
//adapted version of method code from Ext.data.proxy.Server.encodeFilters found in ExtJS 5.1.2.748
/**
* Encodes the array of {@link Ext.util.Filter} objects into a string to be sent in the request url. By default,
* this simply JSON-encodes the filter data
* @param {Ext.util.Filter[]} filters The array of {@link Ext.util.Filter Filter} objects
* @return {String} The encoded filters
*/
encodeFilters: function(filters) {
var out = [],
length = filters.length,
i, filter;
for (i = 0; i < length; i++) {
filter = filters[i];
// Only filters with the two values, property, and value may be serialized
// If it is a filter with a custom filterFn, it cannot be serialized.
if (filter.getProperty() && filter.getValue()!==undefined) { // <===== ADAPTED LINE HERE
out.push(filter.serialize());
}
}
return this.applyEncoding(out);
}
});
Last edited by valio; 10 May 2016 at 4:09 AM.
Reason: (comment fix)
-
Hit me today! Wow 5.1.2 is from October 2015!!! And still no bugfix release for this... Seems there will never be any change regarding the release-cycle at Sencha. Annoying!
-
This bug affects ALL boolean-filters which are defined inside a grid. And still no fix released... Makes me speechless.