Wolfgang
07-21-2007, 08:38 AM
Hello,
Short: How can one assign an expression or template for 'displayField' in a combobox?
Example:
i have an editorgrid where a use a combobox as an editor to select employees.
The grid itself has only the id of the employee, so the CB has its own datastore.
Because i would like to display the entire name and the DS of the combobox contains firstname, lastname seperate, i need to calculate the final 'name' to display it.
Within the grid, i use a custom renderer like this (getting the vales from the CB datastore based on the id)
...
return dsRecord.get('vorname') + ' ' + dsRecord.get('nachname');
...
Now for the selection i found an undocumented option called 'tpl' to define a template for the selection box. So my Cb looks like:
new Ext.form.ComboBox({
typeAhead: false,
triggerAction: 'all',
lazyRender: true,
store: dsMitarbeiter,
displayField: 'nachname',
valueField: 'id',
mode: 'local',
tpl: new Ext.Template('<div>{vorname} {nachname}</div>')
})
But, i have not found a way to set a template or expression for 'displayField'.
So when doubleclick the cell within the grid, the input field shows only the value of 'displayField' not the entire name.
So the grid shows:
beforeedit: 'Donald Duck'
during edit: 'Duck'
during edit combo box selection: 'Donald Duck'
after edit: 'Donald Duck'
Any help/comment is appreciated...
Note: To calculate the entire name on the server side is not an option, because this is a conceptional issue.
Short: How can one assign an expression or template for 'displayField' in a combobox?
Example:
i have an editorgrid where a use a combobox as an editor to select employees.
The grid itself has only the id of the employee, so the CB has its own datastore.
Because i would like to display the entire name and the DS of the combobox contains firstname, lastname seperate, i need to calculate the final 'name' to display it.
Within the grid, i use a custom renderer like this (getting the vales from the CB datastore based on the id)
...
return dsRecord.get('vorname') + ' ' + dsRecord.get('nachname');
...
Now for the selection i found an undocumented option called 'tpl' to define a template for the selection box. So my Cb looks like:
new Ext.form.ComboBox({
typeAhead: false,
triggerAction: 'all',
lazyRender: true,
store: dsMitarbeiter,
displayField: 'nachname',
valueField: 'id',
mode: 'local',
tpl: new Ext.Template('<div>{vorname} {nachname}</div>')
})
But, i have not found a way to set a template or expression for 'displayField'.
So when doubleclick the cell within the grid, the input field shows only the value of 'displayField' not the entire name.
So the grid shows:
beforeedit: 'Donald Duck'
during edit: 'Duck'
during edit combo box selection: 'Donald Duck'
after edit: 'Donald Duck'
Any help/comment is appreciated...
Note: To calculate the entire name on the server side is not an option, because this is a conceptional issue.