View Full Version : load store without autoLoad whe I use form.loadRecord()

22 Dec 2010, 3:01 PM
Hi, anyone can help me with this?

I have a window with a form in it wich I use for add and edit information, when I edit I call the info via getForm.loadRecord(). In the form I have a combobox wich I want load every time I show the window. If I call the window for adding once before I use the window for editing there is not problem to show the correct value in the combobox, but if I try to edit a record before al least show the window once, the combobox show me the valuefield instead the displayfield.

I tried loading the store adding a listener to the window, to the form, even to the combobox using the 'beforerender' event, 'afterrender', 'load', etc.:-?

If I set the autoload property of the store to true there is no problem at all, but I need the store refresh the info every time I call it.8-|

Any light will be appreciated :)

22 Dec 2010, 3:04 PM
LIGHT: Your combobox needs to load its store before setValue will work the way you're trying to work it...

I'm not sure what your code does cuz there is none to see, but are you asking for the combo to load each time it's trigger is pressed? Are you unable to load the store in the window before you call loadRecord?

var combo = new Ext.form.ComboBox({
mode: 'remote',
listeners: {
// delete the previous query in the beforequery event or set
// combo.lastQuery = null (this will reload the store the next time it expands)
beforequery: function(qe){
delete qe.combo.lastQuery;

And the combo will load the store every time the trigger is pressed.

I found that in the docs for combo box (http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.ComboBox), under the property lastQuery.

How is your window set up to work? Does it instantiate once and live forever or do you create a new one and destroy it each time you need one?

23 Dec 2010, 4:36 AM
thanks for answering, actually I figure out what I can do is autoLoad first and reload every time I show the window, but I wondering how to do when I have many stores and I dont want load in the beginings but later. I dont know what event is firing before the loadRecord() act.

Your advice is good, I had not realized that I could reload the combobox every time the trigger is pressed.

by the way, my windows is instanciated every time I need it.

I imagine that problem is because the loading is asynchronic and in the moment the combobox is shown the data is not load yet.

23 Dec 2010, 7:19 AM
Yes, your imagination is right. That's the light at the end of the tunnel. The ugly part, as you've realized, is when you need "cascading" combo boxes. By cascading I mean when you have a combobox whose store loads in response to another value being set in the form. This dependency creates a motherless goat of a problem for us all. I solved it by hooking setValue (see this thread (http://www.sencha.com/forum/showthread.php?118014-Chained-combo-onSetValue&p=548665#post548665)) and throwing an event. Good hunting!

23 Dec 2010, 11:34 AM
thank you very much for your time :)