PDA

View Full Version : [FIXED] [4.2.1 GA] FiltersFeature Filter doesn't apply value for initial filtering



Daniil
4 Sep 2013, 4:35 AM
REQUIRED INFORMATION

Ext version tested:

Ext 4.2.1 GA

Browser versions tested against:

Chrome
IE9

DOCTYPE tested against:

<!DOCTYPE html>

Description:

A FiltersFeature's Filter doesn't apply value for initial filtering

Steps to reproduce the problem:

Just run the test case

The result that was expected:

The grid gets filtered by "true" initially

The result that occurs instead:

The grid appears non-filtered

Test Case:


<!DOCTYPE html>
<html>
<head>
<title>FiltersFeature Filter doesn't apply value for initial filtering</title>

<link type="text/css" rel="stylesheet" href="../resources/css/ext-all.css" />

<script type="text/javascript" src="../ext-all-dev.js"></script>

<script type="text/javascript">
Ext.Loader.setPath('Ext.ux', '../examples/ux');
Ext.require([
'Ext.ux.grid.FiltersFeature'
]);

Ext.onReady(function () {
Ext.create("Ext.grid.Panel", {
renderTo: Ext.getBody(),
store: {
fields: [{
name: "test",
type: "boolean"
}],
data: [
{ test: true },
{ test: false },
{ test: true }
]
},
columns: [{
text: "Test",
dataIndex: "test"
}],
features: [
Ext.create("Ext.ux.grid.FiltersFeature", {
local: true,
filters: [{
type: "boolean",
dataIndex: "test",
value: true
}]
})]
});
});
</script>
</head>
<body>

</body>
</html>

HELPFUL INFORMATION

Debugging already done:

The code which should make filtration is in a Filter's constructor.



Ext.ux.grid.filter.Filter.override({
constructor : function (config) {
Ext.apply(this, config);

this.addEvents(
/**
* @event activate
* Fires when an inactive filter becomes active
* @param {Ext.ux.grid.filter.Filter} this
*/
'activate',
/**
* @event deactivate
* Fires when an active filter becomes inactive
* @param {Ext.ux.grid.filter.Filter} this
*/
'deactivate',
/**
* @event serialize
* Fires after the serialization process. Use this to attach additional parameters to serialization
* data before it is encoded and sent to the server.
* @param {Array/Object} data A map or collection of maps representing the current filter configuration.
* @param {Ext.ux.grid.filter.Filter} filter The filter being serialized.
*/
'serialize',
/**
* @event update
* Fires when a filter configuration has changed
* @param {Ext.ux.grid.filter.Filter} this The filter object.
*/
'update'
);
Ext.ux.grid.filter.Filter.superclass.constructor.call(this);

this.menu = this.createMenu(config);
this.init(config);

if(config && config.value){
this.setValue(config.value);
this.setActive(config.active !== false, true);
delete config.value;
}
}
});



However, this code is not executed till a user opens a header menu. Probably, creation of filters should be forced if any of them is configured with a value config option.
One more observation. This condition will ignore a BooleanFilter's false value.



if(config && config.value){

It can be replaced with:

if(config && Ext.isDefined(config.value)){

Gary Schlosberg
4 Sep 2013, 5:27 AM
Thanks for the report! I have opened a bug in our bug tracker.