PDA

View Full Version : [FIXED] [4.2.2.1144] Ext.form.field.ComboBox#bindStore does not add queryFilter



GustavR
14 Oct 2013, 2:12 AM
REQUIRED INFORMATION
Ext version tested:

Ext 4.2.1.883
Ext 4.2.2.1144

Description:
When binding a new store to a ComboBox the query filter gets lost.

Steps to reproduce the problem:

Create ComboBox with store and queryMode 'local'
Execute a query
Bind another store to the ComboBox
Execute another query

The result that was expected:

The query is executed and the store filtered

The result that occurs instead:

The store is not filtered!

Test Case:
https://fiddle.sencha.com/?fiddle=v7#fiddle/v7


var firstStore = Ext.create('Ext.data.Store', {
fields: ['text'],
data: [{
text: 'foo'
}, {
text: 'bar'
}]
}),
secondStore = Ext.create('Ext.data.Store', {
fields: ['text'],
data: function() {
var data = [];
for (var i = 0; i < 50; i++) {
data.push({
text: 'text_' + i
});
}
return data;
}()
}),
field = Ext.create('Ext.form.field.ComboBox', {
queryMode: 'local',
store: firstStore,
renderTo: Ext.getBody()
});

console.log(field.doQuery('some query text')); // Query executed
console.log(field.getStore().getCount()); // 0 - The store has no items left, all were filtered out

console.log(field.bindStore(secondStore).getStore()); // secondStore - New store bound to combo box
console.log(field.doQuery('some other query text')); // Query executed
console.log(field.getStore().getCount()); // !FAIL! 50 - should be 0


HELPFUL INFORMATION
Possible fix:


Ext.define('Perbility.fix.form.field.ComboBox', {
override: 'Ext.form.field.ComboBox',

onBindStore: function(store) {
var me = this,
filter = me.queryFilter;

me.callOverridden(arguments);

if (filter) {
store.addFilter(filter, false);
}
}
});

Gary Schlosberg
14 Oct 2013, 7:19 AM
Thanks for the report! I have opened a bug in our bug tracker.

utoker
11 Nov 2015, 10:17 PM
Thank you for report and fix.

deniyaltandel
28 Feb 2017, 3:03 AM
I have used below code but still getting issue it was happening when bindstore combo second time and so on but working well if bindstore first time.

onBindStore: function(store) { var me = this,
filter = me.queryFilter;

//me.callOverridden(arguments); if uncommented this one then get error at loading time.

if (filter) {
store.addFilter(filter, false);
}
}