PDA

View Full Version : Ext.FormPanel.load() && ComboBox



Ex_Soft
3 Feb 2012, 12:46 AM
There is the old old problem with Combo Stores not being loaded when the BasicForm sets all the values (http://www.sencha.com/forum/showthread.php?101995-Ext.FormPanel.load%28%29-amp-amp-ComboBox&post478744#post478744) in Ext3. And what about it in Ext4?

friend
3 Feb 2012, 5:10 AM
Combos are still problematic in ExtJs 4... There are several bugs fixes in progress as of v4.0.7 (forceSelection: true and allowBlank: true won't allow you to clear the combo's input field, etc).

If your combo uses queryMode: 'remote' (i.e., Ajax/async store loading), you have to ensure that the combo is fully loaded prior to loading your form or that the combo's store contains at least the one record needed to satisfy the implicit combo.setValue() called by the form panel. I have a form panel which uses about 10 different combos, so this problem causes me a lot of grief. Not to mention, if you're learning the new MVC architecture, you have to figure out how/when to pre-load your stores correctly.

If you manually call combo.setValue('someIDvalue') and the combo's store is not loaded, the combo will automatically set the combos value to null...

So yeah, combos are still a PITA, if you ask me...

Having said that, ExtJs 4 (and the new MVC architecture) is absolutely fantastic. The new Ext.ComponentQuery feature alone is worth the price of admission...

börn
4 Feb 2012, 9:21 AM
So.. when is the correct time to set the values into the form? I currently have the problem that the combo field doesn't select the current value in theist when clicking on the trigger the first time. After clicking a second time this works.... I have several stores in my form and I populate the form with prefatched values in the load event of the last store loaded... So I expected that should solve the timing problem..

I started the store loading in the beforerender phase of my form panel.

We had a similar problem in ext 3.. there we loaded the store data before rendering the html and built up memory stores with the loaded data. This worked very well... But.. I don't like it ;)

friend
6 Feb 2012, 6:04 AM
The "correct" time to load your form panel seems to be only after all Stores used by any comboboxen are loaded. Even then, I have the same problem as you; my combos don't show a value by default.

In order to get my combos prepopulated correctly, I had to add 'cowboy' code in the success method of my form load to call combo.setValue(action.result.data.comboID) a second time (assuming that the form load implicitly called setValue() the first time).

In a real-world application, the new MVC architecture also makes pre-loading/pre-initializing Stores problematic. In my case, I use the Spring Security Framework on the backend and a user is forbidden from calling any of the URL mappings which load a Store if he/she has not yet authenticated. This prevents me from taking advantage of the ExtJs Controller's init or onLaunch methods to preload my stores during the application load.

In my opinion, whomever does development/QA for the combobox still needs to take a good, hard look at the codebase and write several real-world test cases against this class....