mercredi 28 janvier 2015

Why is the initial value of a ComboBox not selected in a special remote case?

Ext JS version: 5.1.0

Suppose we take the Kitchen Sink' remote-combo [exSrc] example



Code:



{
xtype: 'combobox',
reference: 'states',
publishes: 'value',
fieldLabel: 'Select State',
displayField: 'state',
anchor: '-15',
store: {
type: 'remote-states'
},
// We're forcing the query to run every time by setting minChars to 0
// (default is 4)
minChars: 0,
queryParam: 'q',
queryMode: 'remote'
}

and now we expand the config of that combobox with


Code:



value: 'Alaska',
forceSelection: true,

Thus creating a combobox which accepts existing states only, displayField equals valueField and its intitial value should be set to 'Alaska'.

A peek into the implementation of doSetValue [impl] reveals that the combobox would not select that initial value.


1. value is 'Alaska' thus value != null

2. isLoaded = store.getCount() > 0 || store.isLoaded() is false because we have a store querying remote data on demand

3. displayIsValue = me.displayField === me.valueField is true

4. for that reason the code skips the store.load();

5. if (!record || !record.isModel) { will be entered but no record is found because the store is not loaded yet

7. if (!record) { is entered but

8. if (!forceSelection) { is not entered

9. thus matchedRecords.push(record); is not called for the current value

10. finally valueChanged is still undefined


Thus the initial value is (more or less) ignored and the box will not select it.


Is this the intended behavior or a bug?


[exSrc]: http://ift.tt/1wB2Hoq

[impl]: http://ift.tt/1wB2Fgz






Why is the initial value of a ComboBox not selected in a special remote case?

Aucun commentaire:

Enregistrer un commentaire