You found a bug! We've classified it as
EXTJS-8688
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
-
Sencha Premium User
Combobox with autoLoad store applies Filter?
I have a combobox that is configured to use a store that is being autoLoaded. I noticed some code was added to the combobox class to auto-add a queryFilter based on the displayfield:
Code:
// Create the filter that we will use during typing to filter the Store
me.queryFilter = new Ext.util.Filter({
id: me.id + '-query-filter',
disabled: true,
root: 'data',
property: me.displayField
});
However it is disabled by default so I was puzzled when I saw it being added to my store autoload query string parameters:
Code:
method:getSalesReps
_dc:1360768150232
page:1
start:0
limit:25
filter:[{"property":"full_name"}]
Is this the expected behavior? This is causing problems because I had always assumed that there would be a value parameter as well as a property parameter whenever a filter querystring was sent back to the server.
-
What Ext JS 4.x.x version? And can I get a locally runnable testcase?
-
Sencha Premium User

Originally Posted by
mitchellsimoens
What Ext JS 4.x.x version? And can I get a locally runnable testcase?
Here are the script and css tags I'm referencing:
Code:
<link href="http://cdn.sencha.com/ext/beta/4.2.0.489/resources/ext-theme-classic/ext-theme-classic-all.css">
<script src="http://cdn.sencha.com/ext/beta/4.2.0.489/ext-all-dev.js"></script>
I'm using the latest beta for 4.2.0.489. Here is my code:
Code:
Ext.onReady(function() {
Ext.define('SR', {
extend: 'Ext.data.Model',
idProperty: 'id',
fields: [
{name: 'id', type: 'int'},
{name: 'full_name', type: 'string'},
{name: 'phone', type: 'string'},
{name: 'title', type: 'string'},
{name: 'email', type: 'string'}
]
});
var myStore = Ext.create('Ext.data.Store', {
autoLoad: true,
model : 'SR',
proxy : {
type : 'ajax',
url : '/com/qlp/crm/order/OrderStatusService.cfc?method=getSalesReps',
reader : {
type : 'json',
root : 'root'
}
}
});
var combo = Ext.create('Ext.form.field.ComboBox', {
renderTo : Ext.getBody(),
name : 'sales_rep_filter',
fieldLabel : 'Sales Rep',
labelWidth : 75,
anchor : '99%',
store : myStore,
queryMode : 'local',
enableKeyEvents : true,
multiSelect : true,
editable : false,
displayField : 'full_name',
valueField : 'id',
emptyText : 'Select a Sales Rep',
value : 0
});
});
The idea being that I want to load all the data from the server once and then the combobox can just treat it as querymode: local.
I'll try to attach a screen shot of my the http request parameters:
queryString.jpg
-
Sencha Premium Member
Same problem
I have same problem in our system with Ext JS 4.2.0.489 RC1 version
REQUIRED INFORMATION
Ext version tested:
Browser versions tested against:
Description:
- Parameter filter=[{"property":"name"}] is automaticaly added into combobox store load request parameters
Steps to reproduce the problem:
- Try example and see request parameters in firebug
The result that was expected:
- No additional filter parameters in request
The result that occurs instead:
- Parameter filter=[{"property":"name"}] appeared in request parameters
Test Case:
Code:
Ext.define( 'myModel', {
extend: 'Ext.data.Model',
proxy: {
type: 'ajax',
url: '/users.json',
reader: {
type: 'json',
root: 'users'
}
},
fields: [
{
name: 'id',
type: 'integer',
required: true,
label: 'Id'
},
{
name: 'name',
type: 'string',
required: true,
label: 'Name'
},
]
} );
Ext.application( {
name: 'Combo test',
appFolder: '',
launch: function() {
var me = this;
var store = Ext.create('Ext.data.Store', {
model: 'myModel',
data : []
});
var formPanel = Ext.create('Ext.form.Panel', {
title: 'Test form',
items: [{
id: 'combo',
name: 'combo',
fieldLabel: 'Combobox',
xtype: 'combobox',
store: store,
displayField: 'name',
valueField: 'id'
}],
buttons: [{
text: 'Submit',
formBind: true,
handler: function() {
var form = this.up('form').getForm();
form.getValues();
}
}]
});
Ext.create( 'Ext.container.Viewport', {
layout: 'fit',
renderTo: Ext.getBody(),
items: [ formPanel ]
} );
}
} );
-
Sencha Premium Member
Same issue still exists In 4.2.0 (release)
-
This has been reported, and fixed in the codebase. The override is available here: http://www.sencha.com/forum/showthre...l=1#post946177
-
Sencha Premium User
What about when you do a store.load(). It seems that the filter is still applied because the override is only for the filter() function. Should the same allDisabled logic be applied here so that disabled filters aren't sent with the store.load() method?
From Ext.data.AbstractStore.load:
Code:
load: function (options) {
var me = this,
operation;
options = Ext.apply({
action: 'read',
filters: me.filters.items,
sorters: me.getSorters()
}, options);
me.lastOptions = options;
operation = new Ext.data.Operation(options);
if (me.fireEvent('beforeload', me, operation) !== false) {
me.loading = true;
me.proxy.read(operation, me.onProxyLoad, me);
}
return me;
},
-
Yes, disabled filters should not be applied.
-
Sencha User
I am still seeing a bug here.
The combobox initcomponent does:
Code:
me.queryFilter = new Ext.util.Filter({
id: me.id + '-query-filter',
disabled: true,
root: 'data',
property: me.displayField
});
store.filter(me.queryFilter);
If you have remoteFilter:true and any non-disabled filters defined, this will trigger a load even if autoload is false when the combo/store are initialized.
I think a solution may be to do
Code:
store.filters.add(me.queryFilter);
instead, not triggering a load...but adding the filter to the array.
Last edited by Sharkanana; 22 Apr 2013 at 7:12 AM.
Reason: adding possible solution