Skip to content

Instantly share code, notes, and snippets.

@joelwatson
Last active July 6, 2017 14:31
Show Gist options
  • Save joelwatson/e255a2f6c6ebf39ccaf18288d96acf0f to your computer and use it in GitHub Desktop.
Save joelwatson/e255a2f6c6ebf39ccaf18288d96acf0f to your computer and use it in GitHub Desktop.
Retrieving value from ComboBox via displayField
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']
]
}
});
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