PDA

View Full Version : Set default value for combo



rafaelrp
30 May 2012, 5:38 AM
Hello!

I have a combo with a store that is generated by php and and i need to set a default value for one of this values returned by php in that combo, how i can set this default value?

combo:


{
fieldLabel : 'list',
name : sel',
id : 'sel',
xtype : 'combo',
editable : false,
allowBlank : false,
displayField : 'grupo',
valueField : 'value',
emptyText : 'Selecione...',
listConfig: {
getInnerTpl: function (displayField) {
return '<div data-qtip="{central}">{' + displayField + '}</div>';
}
},
store : Ext.create('Ext.data.Store', {
fields : ['grupo', 'value', 'central'],
<?
$data = "";
while(OCIFetchInto($res, $row, OCI_ASSOC)){
$data .= "{grupo : '".$rowGrupos['desc']."', value : '".$rowGrupos['ID_GRUPO']."', central : '".$rowGrupos['cent']."'},";
}
$data = rtrim($data, ",");
?>
data : [
<?=$data?>
]
})


Thanks ! ~o)

Tim Toady
30 May 2012, 5:51 AM
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.Field-cfg-value

rafaelrp
30 May 2012, 5:53 AM
i need to select a value from the combo, not set value in the field, there's a way i can do that?

Thx!

Tim Toady
30 May 2012, 6:03 AM
I don't understand the difference. Setting the value property will automatically select the value when the store is loaded. Perhaps I am not understanding your question.

rafaelrp
30 May 2012, 6:20 AM
yes, my mistake, setting value works !

Thanks !~o)