PDA

View Full Version : Default Combobox value not selected



AJAIN32
15 May 2014, 9:26 PM
Hi,

I have been trying to set a combobox value by default when the combox renders on the page.
before that i am loading data in the combobox store.
combo.store.loadData(data);
combo.setValue(value) // value is a code value from the store only

In combox configuration i have selected queryMode : local.

I am not sure why combobox is not getting rendered with the value i am specifying, data is loading properly.

I got the issue as it is working when i called the setValue method on some event, but can anyone please tell me that is there any callback for loadData method ??
or how can i make it in sync, i am using loadData method because the store is without any proxy and reader i am just filling the data in the store and binding it to the combobox.



Please help !!

Thanks in advance
Ankit

Zinnia
15 May 2014, 11:35 PM
Have you declared the valueField and displayField config option in combobox. Check the below example, it is working fine in my end

AJAIN32
16 May 2014, 12:14 AM
Yes, I have declared Value and display field property.
I have a master store having values of multiple comboboxes and in success load of that i am loading the data into a local store and then setting the value. but its not happening.

Ext.getStore('masterStore').load({

callback: function (records,options, success)
{
if(success)
{
var combo = Ext.getCmp('comboId');
combo.store.loadData(records.raw.xyz)
// till this point its working fine, data is getting loaded into respective combo box
combo.setValue(Value);
// the value is correct

}
}
});

So this is the issue, somehow its not going into sync.

Please help !!

jsakalos
16 May 2014, 4:56 AM
Check first if Value can be found in the combo store.

The easiest way is to set value:Value config option on the combo - you can try that.

AJAIN32
18 May 2014, 9:43 PM
Yes, i have checked that value is there.

The problem may be the combo store is not having all the values when the .setValue got excecuted.

Is loadData method works async ??

jsakalos
18 May 2014, 9:53 PM
loadData is not async (or it shouldn't be), only remote store load is. There must be something else wrong. Try to set the value from console.

AJAIN32
19 May 2014, 3:35 AM
Thanks for reply,

i am not sure about the excact error, but now it is working after restructuring. i have just seprated out the functions.

thanks