PDA

View Full Version : setValue in combobox strange result



italoc
27 Aug 2009, 11:09 PM
this is my combobox code:

var notaSelectEdit = new Ext.form.ComboBox({
fieldLabel: 'N° nota AIFA',
id: 'editaifa',
xtype: 'combo',
hiddenId: 'idnew',
hiddenName: 'idnota',
displayField: 'n_nota',
valueField: 'id',
loadingText: 'Ricerca...',
pageSize: 40,
minChars: 0,
queryDelay: 500,
width: 530,
labelWidth: 530,
triggerAction: 'all',
forceSelection: true,
name: 'editaifa',
store: nota,
typeAhead: false,
emptyText: 'Seleziona la nota...',
allowBlank: false,
tpl: notaTpl,
itemSelector: 'div.search-item'
});

and i try to set the value with this command:

notaSelectEdit.setValue(idofthevaluedisplay);

i this way i see the ID in the combobox and not the related value.

if i try with this command:

notaSelectEdit.setValue(valuedisplay);

in this way i see the correct Value in the combobox but when i submit the form don't submit the ID of the value displayed...

if i select the value from the list manually all work perfect and the submit sent the ID of the value displayed..

can you help? what's wrong??

thank you

jay@moduscreate.com
28 Aug 2009, 5:09 AM
If the store is not loaded, then it cannot set the "display" value

tcl_java
28 Aug 2009, 11:48 AM
you can add listeners to store nota


nota.on("load", function(store){
notaSelectEdit.setValue(idofthevaluedisplay);
});

Condor
29 Aug 2009, 3:05 AM
Or use the override from this feature request (http://www.extjs.com/forum/showthread.php?t=75751).

Nagadev
29 Aug 2009, 12:02 PM
notaSelectEdit.setValue(idofthevaluedisplay);
notaSelectEdit.lastSelectionText = valuedisplay;

But you need to make sure that the combo is loaded with options already