doncoleman
22 Dec 2010, 3:57 PM
I'd like to display a person's name in a Select control. The model has first and last name as 2 fields.
I think I need to create a virtual field "name" on the model, or use a template in the select. I can't get either to work.
Is there a standard way to do this?
Ext.regModel('Employee', {
fields: [
{name: 'first_name', type: 'string'},
{name: 'last_name', type: 'string'}
// ...
],
name: function() {
// returns the correct value, but doesn't work for Ext.form.Select#displayField
return this.first_name + " " + this.last_name;
}
});
{
xtype: 'selectfield',
id: 'employeeSelect',
name: 'name',
label: 'Name',
store: employeeStore,
valueField: 'code',
// tpl: '{first_name} {last_name}', // Doesn't work
// tpl: displayField: 'name', // Doesn't work
displayField: 'first_name'
}
I think I need to create a virtual field "name" on the model, or use a template in the select. I can't get either to work.
Is there a standard way to do this?
Ext.regModel('Employee', {
fields: [
{name: 'first_name', type: 'string'},
{name: 'last_name', type: 'string'}
// ...
],
name: function() {
// returns the correct value, but doesn't work for Ext.form.Select#displayField
return this.first_name + " " + this.last_name;
}
});
{
xtype: 'selectfield',
id: 'employeeSelect',
name: 'name',
label: 'Name',
store: employeeStore,
valueField: 'code',
// tpl: '{first_name} {last_name}', // Doesn't work
// tpl: displayField: 'name', // Doesn't work
displayField: 'first_name'
}