PDA

View Full Version : [SOLVED!] ComboBox renders valueField instead of DisplayField upon form.load



JoyfulBobHome
25 Feb 2010, 12:55 PM
Searched the forums but couldn't find an answer.

I've got a dynamic CB that works fine. However, when I load an existing record via form.load() the CB displays the valueField instead of the DisplayField. If I then select a different value from the list it displays the name, but not initially when the form is loaded.

I've tried using ACTNOfield.reset() in an attempt to re-render/re-display it properly w/o success.

Here's my CB:


ACTNOfield = new Ext.form.ComboBox({
xtype: 'combo',
id: 'ACTNOfield',
fieldLabel: 'AE',
forceSelection: true,
displayField: 'ACTNM',
valueField: 'ACTNO',
hiddenName: 'ACTNO',
minChars: 1,
triggerAction: 'ACTNO',

lazyRender: false,
loadingText: 'Loading AE\'s...',

typeAhead: true,
resizable: true,
queryDelay: 5,
listWidth: 220,

store: excStore,
tpl: excTpl,
itemSelector: 'div.combo-result-item',
totalProperty: 'total', // enable paging
pageSize: 0, // enable paging
width: 200
});

Here's the store:

var excTpl = new Ext.XTemplate(
'<tpl for="."><div class="combo-result-item">',
'<div class="combo-full-address">{ACTNM} : {ACTNO}</div>',
'</div></tpl>'
);

var excStore = new Ext.data.Store({
id: 'excStore',
proxy: new Ext.data.HttpProxy({
url: 'ACTEXC',
method: 'POST'
}),
baseParams: {
submit: 'RETRIEVE',
process: 'INQUIRE',
processType: 'LIST',
cgirequest: 'LOADCB',
dbfile: 'ACTEXC',
actnmi: ''
},

reader: new Ext.data.JsonReader({ // we tell the datastore where to get his data from
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{ name: 'ACTNO', type: 'int' , mapping: 'ACTNO' }
, { name: 'ACTNM', type: 'string' , mapping: 'ACTNM' }
])
});

25 Feb 2010, 1:03 PM
is the combo's store loaded?

DAT
25 Feb 2010, 1:16 PM
No, it's not; it is only when they type characters to load it.

That makes sense that it can't display the value if the store isn't loaded. So the answer is to load the store first time into the page so that the .load will find the value to display it???

(Note ths is DAT with Joyful Bob sitting here.)

25 Feb 2010, 1:20 PM
Yes, load the form after the combo's have loaded.

JoyfulBobHome
25 Feb 2010, 1:54 PM
That did it!

Thanks so much, Jerry! :D

P.S. We just LOVE your ExtJS in Action book! We've learned a lot more of the fundamentals of ExtJS in addition to what we already knew, plus a lot more of what's possible. =D>=D>=D>

25 Feb 2010, 2:00 PM
it's *jay* :)

glad the book helped you :)