PDA

View Full Version : [3.3.0] combo does not clearing filter on store after select value



matei
20 Oct 2010, 4:36 AM
Ext version tested:

Ext 3.3.0
Ext 3.2.1


Description:

Modify http://dev.sencha.com/deploy/dev/examples/form/form-grid.html, and change Rating to be a combobox not radiogroup.
combo is showing valueField not displayField


Test Case:
change in file: examples/form/form-grid.html


/*{xtype: 'radiogroup',...},*/ // comment radiogroup, and add combo
new Ext.form.ComboBox({
fieldLabel: 'Rating',
name: 'rating',
mode: 'local',
store: [[0, 'A'], [1, 'B'], [2, 'C']],
typeAhead: true,
forceSelection: true,
triggerAction: 'all'
})


Steps to reproduce the problem:

select first item in grid
in company details combo rating will have some value
clear that value and type : 'A'
select item 'A' from combo (make sure before select this combo list view has only 1 value = 'A')
select from grid another item that has Rating = 'B'
now in Rating combo will be '1' not 'B'
if select one company that has rating 'A' combo will display corectly


Possible fix:


Ext.override(Ext.form.ComboBox, {
postBlur: Ext.form.ComboBox.prototype.postBlur.createSequence(function(){
if(this.editable && this.clearFilterOnReset){
this.store.clearFilter();
}
})
});

Seana
20 Oct 2010, 7:54 AM
Your combo box isn't defining


displayField:,
valueField:

though passing an array directly as a store I'm not sure how you would do so.

I would think something more like



record = Ext.data.Record.create([
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' }
]);

var combo = new Ext.form.ComboBox({
fieldLabel: 'Rating',
name: 'rating',
displayField:'name',
valueField: 'id',
mode: 'local',
store:{
reader: new Ext.data.ArrayReader({
idIndex: 0
}, record)
},
typeAhead: true,
forceSelection: true,
triggerAction: 'all'
});
combo.getStore().loadData([[0, 'A'], [1, 'B'], [2, 'C']]);

would do the trick

granted that's untested and off the top of my head.

Seana
20 Oct 2010, 8:15 AM
Ok took and tested (in 3.3.0) while I was eating lunch...


replacing the following in 'form-grid.js'


{
xtype: 'radiogroup',
columns: 'auto',
fieldLabel: 'Rating',
name: 'rating',
// A radio group: A setValue on any of the following 'radio' inputs using the numeric
// 'rating' field checks the radio instance which has the matching inputValue.
items: [{
inputValue: '0',
boxLabel: 'A'
}, {
inputValue: '1',
boxLabel: 'B'
}, {
inputValue: '2',
boxLabel: 'C'
}]
}

with...


{
xtype: 'combo',
fieldLabel: 'Rating',
name: 'rating',
mode: 'local',
displayField:'name',
valueField: 'id',
store: new Ext.data.ArrayStore({
idIndex: 0,
fields: [{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' }],
data:[[0, 'A'], [1, 'B'], [2, 'C']]
}),
typeAhead: true,
forceSelection: true,
triggerAction: 'all'
}


results in the correct functionality

matei
20 Oct 2010, 10:54 AM
1) store: can be Ext.data.Store/Array (check in docs) (I tried to make it simple)
2) also this way is not working
3) if you edit combo while typeing letter 'A' the list view will have only 1 item = 'A' -> then select it. then try to select item that has 'B' in left grid so you will see '1' not 'B'


Ok took and tested (in 3.3.0) while I was eating lunch...


replacing the following in 'form-grid.js'


{
xtype: 'radiogroup',
columns: 'auto',
fieldLabel: 'Rating',
name: 'rating',
// A radio group: A setValue on any of the following 'radio' inputs using the numeric
// 'rating' field checks the radio instance which has the matching inputValue.
items: [{
inputValue: '0',
boxLabel: 'A'
}, {
inputValue: '1',
boxLabel: 'B'
}, {
inputValue: '2',
boxLabel: 'C'
}]
}

with...


{
xtype: 'combo',
fieldLabel: 'Rating',
name: 'rating',
mode: 'local',
displayField:'name',
valueField: 'id',
store: new Ext.data.ArrayStore({
idIndex: 0,
fields: [{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' }],
data:[[0, 'A'], [1, 'B'], [2, 'C']]
}),
typeAhead: true,
forceSelection: true,
triggerAction: 'all'
}


results in the correct functionality

Seana
20 Oct 2010, 11:42 AM
1) store: can be Ext.data.Store/Array (check in docs) (I tried to make it simple)
2) also this way is not working
3) if you edit combo while typeing letter 'A' the list view will have only 1 item = 'A' -> then select it. then try to select item that has 'B' in left grid so you will see '1' not 'B'

#1) I was pointing out that I wasn't sure how to use display/valueField tags with a straight array, not that it wasn't valid.

#2/3) I wasn't typing in the combobox, I was merely clicking. Initially I thought it was an issue with possibly selecting the wrong field in the data array you were passing, however that isn't the case.

The real issue here appears to be with loadRecord and not selecting value. I encountered this a few months back but because my combo was being loaded via Ext.Direct I thought it was a latency issue.

matei
20 Oct 2010, 11:48 AM
understand, but even loadRecord, and display/valueField are not necesary, problem is the filter on combo store that remains filtered after you type in combo textfield and is not cleared after finish editing (end select needed value).


#1) I was pointing out that I wasn't sure how to use display/valueField tags with a straight array, not that it wasn't valid.

#2/3) I wasn't typing in the combobox, I was merely clicking. Initially I thought it was an issue with possibly selecting the wrong field in the data array you were passing, however that isn't the case.

The real issue here appears to be with loadRecord and not selecting value. I encountered this a few months back but because my combo was being loaded via Ext.Direct I thought it was a latency issue.

Seana
20 Oct 2010, 11:59 AM
I've been pondering this a little bit my question here, should setting the value on a combo box implicitly cause an associated Store to clear it's filters?