/** * @private */Ext.define('Ext.grid.plugin.filterbar.filters.SingleFilter', { extend: 'Ext.grid.plugin.filterbar.filters.Base', initFilter: function(config) { var me = this, filter, value; value = me.value; filter = me.getStoreFilter(); if (filter) { // This filter was restored from stateful filters on the store so enforce it as active. me.active = true; me.setOperator(filter.getOperator()); } else { // Once we've reached this block, we know that this grid filter // doesn't have a stateful filter, so if our flag to begin saving // future filter mutations is set we know that any configured filter must be nullified // out or it will replace our stateful filter. if (me.grid.stateful && me.getGridStore().saveStatefulFilters) { value = undefined; } me.active = me.getActiveState(config, value); filter = me.createFilter({ operator: me.operator, value: value }); if (me.active) { me.addStoreFilter(filter); } } if (me.active) { me.setColumnActive(true); } me.filter = filter; }, setValue: function(value) { var me = this; me.filter.setValue(value); if (Ext.isEmpty(value)) { me.setActive(false); } else if (me.active) { me.value = value; me.updateStoreFilter(); } else { me.setActive(true); } }, activate: function() { this.addStoreFilter(this.filter); }, deactivate: function() { this.removeStoreFilter(this.filter); }, resetFilter: function() { var me = this, filter, field, value; if (me.changingFilters) { return; } filter = me.getStoreFilter(); field = me.getField(); if (filter) { me.active = true; value = filter.getValue(); me.setOperator(filter.getOperator()); } else if (me.active) { me.setActive(false); } field.suspendEvents(); field.setValue(value); field.resumeEvents(true); } });