PDA

View Full Version : Double load of combo box store



Geziefer
9 Nov 2010, 6:40 AM
Hello,

I have a ComboBox with lazyInit set to false and a JsonStore connected to it with autoLoad set to true.
Now, when I add a listener to the load event, I experience that it is called once at the start when displaying the panel and once again when I click the combo box button (also the 'loading' message appears in the combo box).
In my understanding, the 2nd call should not appear, since the content is already loaded.
Any ideas why it behaves like that and what I may have to do additionally for not loading twice?

Regards,
Geziefer

plalx
9 Nov 2010, 6:52 AM
Have you configured your combobox with mode: 'local' ?

Geziefer
9 Nov 2010, 7:31 AM
Thank you for your quick reply - it seems to solve my problem!

Yet, I don't understand the mode property - in deed, it does say in the API "Automatically loads the store the first time the trigger is clicked.", but why do I have to use 'local'? I thought, it was only for constant data, which the client side script can set by itself and 'remote' was for data which gets loaded from a server url. Is that not correct?

Geziefer

darthwes
9 Nov 2010, 7:34 AM
You're loading the store prior to the user triggering the combo?

Geziefer
9 Nov 2010, 7:39 AM
Well, I have set autoLoad to true and see my jsp to get executed when opening the view, just as I wanted.
So, is the data in that case regarded as local since it was loaded into the store at the beginning?

darthwes
9 Nov 2010, 7:44 AM
Sure, it's cached (local) after you load it. So if you put your combo's mode on 'remote' it will query the server (reload the store) a second time. The combo should work either way, AFAIK, you just end up loading the store twice.

Geziefer
9 Nov 2010, 8:01 AM
Ok, I got it - thanks!

One more thing which has to do with the same setup - I like to preselect the first value which comes back from the store after loading it. Shouldn't that be done by the autoSelect property?
By now, I set the first value manually in the load listener.

Condor
9 Nov 2010, 8:13 AM
autoSelect:true only works when the combobox has the focus when the store is loaded (which usually only happens with mode:'remote' comboboxes).

Geziefer
9 Nov 2010, 8:17 AM
Thank you guys - I'm really impressed of the short response time in this forum! :-)