PDA

View Full Version : ComboBox and reset



couetbis
9 Apr 2010, 7:57 AM
Hi,
I use a combobox with forceSelection option.
For example I type Ohio2, it forceSelection to Ohio. It's ok.
But when I reset combo (with reset form), id is show and not label.
How to resolve this problem, is it a bug ?
Thanks in advance

ShatyUT
9 Apr 2010, 8:33 AM
Can you post your code? It's impossible to say what you are doing wrong without seeing what you are doing.

couetbis
13 Apr 2010, 7:50 AM
My code :



Ext.onReady(function(){
var panelEnglobant = new Ext.Panel({
border: false,
title: '',
layout: 'form',
bodyStyle :'padding:10px 10px 10px 10px',
items : [
new Ext.form.FormPanel({
border: false,
title: 'Pays',
id:'idFormulaire',
baseCls: 'x-panelTitre',
name: 'edFormulaire',
monitorValid:true,
reader : new Ext.data.JsonReader(),
trackResetOnLoad: true,
labelAlign: 'left',
labelWidth: 180,
layout: 'form',
bodyStyle : 'padding:30px 10px 10px 30px',
items : [
new Ext.Panel({
id:'panelBoutonsFormulaire',
border: false,
items:[
new Ext.Panel({
id:'boutonInitialiserFormulaire',
width:102,
style: 'float:right',
border:false,
layout: 'form',
items: [
new Ext.Button({
id: 'initialiserFormulaire',
cls:'x-btn-text',
cls:'boutonAlignementCentre',
minWidth: 100,
text: 'Initialiser',
handler : function (){
var formulaire = Ext.getCmp('idFormulaire');
if(formulaire != null)
{
formulaire.getForm().reset();
}
}
})
]
}),
]
}),
new Ext.form.TextField({
fieldLabel: 'Libellé',
name: 'edPays___libelle',
labelSeparator: '',
focusClass: 'zoneFocusForm',
width:190,maxLength:100,readOnly: false,
id:'idPays___libelle'
}),
new Ext.form.ComboBox({
fieldLabel: 'Devise',
hiddenName:'edPays___idDevise',
labelSeparator: '',
focusClass: 'zoneFocusForm',
store: new Ext.data.JsonStore({
fields : ['id','texte'],
id: 'id',
root: 'enregistrements',
autoLoad: true,
url: 'IPaysBP',
baseParams : {"FORMATS_CLIENT":"CDS:ComboFormulaire", "OPERATION":"chargerDevises" },
listeners: {
load: function(){
var cb=Ext.getCmp('idPays___idDevise');
cb.setValue(cb.value);
cb.render();
}
}
}),
mode:'local',
valueField:'id',
displayField:'texte',
typeAhead: true,
triggerAction: 'all',
selectOnFocus:true,
maxHeight: 150,
forceSelection: true,
width:190,
id: 'idPays___idDevise'
})
]
})]
});
panelEnglobant.render('contenuDeLaPage');
chargerPage();
});


Form is charged with ajax request.
Combo contain id-values (1, France), (2, USA).
I modified combo content with France1, this label doesn't exist so with forceSelection option, definitive value is France.
Then I click on "initialiser" button (reset) and combo value becomes 1 (id) and not France.

Sorry for my bad english.