PDA

View Full Version : combo not sending valuefield onload



jpcoppol
15 Nov 2010, 9:42 AM
I load a combo box and set the hiddenName and ID. When I select a item from the dropdown, it passes the valueField. the problem is if I don't do anything, even though I set the default to the first record in the store, it passes the diplayField. Anybody know why?

jpcoppol
15 Nov 2010, 9:43 AM
ddtimeperiodStore.on('load', function() {
Ext.getCmp('timeperiod').setValue(this.getAt(0).data.PERIODTYPE);
});
ddtimeperiodStore.load();
id : 'frmmain3',
layout : 'form',
padding : 4,
height : '100%',
columnWidth: .25,
border : false,
margin : '0 0 0 0',
labelAlign : 'top',
items:
[
{
xtype : 'combo',
id : 'timeperiod',
fieldLabel : 'Time Period',
triggerAction : 'all',
store : ddtimeperiodStore,
name : 'timeperiod',
hiddenName : 'timeperiodId',
mode : 'local',
displayField : 'PERIODTYPE',
valueField : 'TIMEPERIODID'
}
]
var timeperiodStore = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
timeperiodStore.superclass.constructor.call(this, Ext.apply({
storeId: 'timeperiodStore',
url: 'components/ddtimeperiod.cfc?method=timeperiod',
autoLoad: false,
fields: [
{
name: 'TIMEPERIODID',
mapping: 'TIMEPERIODID'
}
,{
name: 'PERIODTYPE',
mapping: 'PERIODTYPE'
}
]
}, cfg));
}
});

jpcoppol
15 Nov 2010, 9:47 AM
This is how I make the call to show the displayField.

alert(Ext.getCmp('timeperiod').value);

qooleot
16 Nov 2010, 6:56 AM
Hey a couple suggestions - first it would be easier to read code that has been formatted (there are plenty of free IDEs out there that will auto-format javascript) and has been put in the code tags (via the button in the forum post editor).

As for your specific issue, don't use the combobox.value but rather the API's combobox.getValue() function. Hope this helps!