PDA

View Full Version : Set Combobox value and display Field by Loading Record in Form



h.martiker
26 Dec 2012, 6:37 AM
Hey everybody,

I have a Combobox assigned to a DirectStore. When the user inputs some text the Store send a request to the backendserver. Everything works fine so I can select the article from the Store and the value and displayFields gets populated.
But the Combobox is also member of a Dataform. When I load the model in the form all Fields get populated except the combobox. I think there is only the displayField missing.
But I checked that the valueField of the combobox will be filled if the article is still an item of the store. (e.g. last Search)

So is it possible to fill the displayField from the Load-Method of the Form e.g. by creating a model with a displayField and valueField for the Datafield of the article-number?


{
{
xtype: 'combobox',
anchor: '100%',
listConfig: {
loadingText: 'Suche nach Artikeln...',
emptyText: 'Keinen Artikel mit dieser Artikelnummer gefunden!',
getInnerTpl: function() {
return '<div class="search-item"><b>{artikelnummer}</b><br>{kurztext}</div>';
}
},
itemId: 'artikelnummer',
name: 'artikelnummer',
fieldLabel: 'Artikelnummer',
selectOnFocus: true,
hideTrigger: true,
displayField: 'artikelnummer',
forceSelection: true,
minChars: 2,
queryCaching: false,
queryDelay: 50,
queryParam: 'queryArtikelnummer',
store: 'Artikelsuche',
typeAhead: true,
valueField: 'artikelnummer',
listeners: {
select: {
fn: me.onArtikelnummerSelect,
scope: me
}
}
},

mitchellsimoens
28 Dec 2012, 8:59 AM
If there is no data in the store bound to the combobox, it will only display the value you set on it as it doesn't know of any displayField value to match that value.