Last active
July 6, 2017 14:31
-
-
Save joelwatson/e255a2f6c6ebf39ccaf18288d96acf0f to your computer and use it in GitHub Desktop.
Retrieving value from ComboBox via displayField
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.define('Sandbox.view.test.combobox.Base', { | |
extend: 'Ext.form.field.ComboBox', | |
id: 'futureCmp', | |
displayField: 'text', | |
valueField: 'id', | |
store: { | |
fields: ['id', 'text'], | |
data: [ | |
[1, 'Apples'], | |
[2, 'Oranges'] | |
] | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('should select correct value from displayField', function () { | |
var combo = ST.comboBox('@futureCmp'); | |
combo | |
.execute(function (cmp) { | |
var record = cmp.findRecordByDisplay('World'); | |
// we're in the target context now, so we *can* | |
// interact with Ext JS now | |
// we could return an object if needed, but we only need the id | |
return record ? record.get('id') : false; | |
}) | |
.and(function () { | |
// "executeResult" is the value returned from execute() | |
// in this case, it's the id of the item we want to select | |
var id = this.future.data.executeResult; | |
combo.setValue(id); | |
// assert that the value has been correctly selected | |
combo.value(id); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment