PDA

View Full Version : combobox and xml



u007
16 Aug 2007, 11:20 PM
i've initialise my simplestore
and set it into combobox config.

and then on a event, i load the xml data...
and populate the data onto the combobox.store.loaddata( )

in which the data is a array [ [ , ], [ , ] ]
which i've used array.push to generate it.

but when i setvalue( rawvalue ), not the label of the combo,
but the raw value of the combo, the combo does not show the label
but instead, show the raw value..

when i setrawvalue( rawvalue ), the combo show the raw value..
when i click on the drop down arrow, it scroll to the label value..

but why isn't it auto select the value on the combo?
why does it show rawvalue?

i even tried selectByValue, still no luck :(

please help...



var list_edit_currency_options = [

];
var store_currency = new Ext.data.SimpleStore( {
fields: ['option_value','option_label'],
data: list_edit_currency_options
} );

tcombo = new Ext.form.ComboBox( {
id: 'field_add_currency',
name: 'field_add_currency',
fieldLabel: "Currency",
width: 210,
maxLength: 100,
allowBlank: false,
store: store_currency,
displayField:'option_label',
valueField: 'option_value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText: 'Please select',
//selectOnFocus: true,
forceSelection: true,
value: 'RM'
} );


Ext.getCmp('field_add_currency').store.removeAll();

//some code truncated out..
//
// xyzarray => [ ['xxx','xxxxx], ['yyyy', 'yyyyyyy'] ]
//
Ext.getCmp('field_add_currency').store.loadData( xyzarray );


//my value here is
Ext.getCmp('field_add_currency').setValue( new_ds.getAt(0).get('currency') );

u007
18 Aug 2007, 5:09 AM
i even tried

Ext.getCmp('field_add_currency').select( 2, true );

no effect... like nothing happened.. :(

u007
18 Aug 2007, 5:51 AM
i've managed to setvalue successfully,
by setting
var store_currency = new Ext.data.SimpleStore( {
fields: ['value','text'],
data: list_edit_currency_options
} );

tcombo = new Ext.form.ComboBox( {
id: 'field_add_currency',
name: 'field_add_currency',
fieldLabel: "Currency",
width: 210,
maxLength: 100,
allowBlank: false,
store: store_currency,
displayField:'text',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText: 'Please select',
//selectOnFocus: true,
forceSelection: true,
value: 'RM'
} );

but this is odd, i thought we have rights to change the name?

2nd question, why is combobox submitting "text" value instead of "value" value??
omg....

u007
18 Aug 2007, 6:04 AM
Dang!

hiddenName points to the right combobox value on post... :S