PDA

View Full Version : Combobox with different value field displays the value field in text area



Fire-Dragon-DoL
31 May 2012, 11:26 AM
I'm using combo box with a store (local), and I have a display field and a value field.

Everything is working fine except that when the combobox is shown again (i'm using the row editor so the combobox is shown a lot of times), it shows in the box where you can write the value field instead of the display field.

Are there any way to solve this issue?

scottmartin
31 May 2012, 12:11 PM
Can you show a screen of what you are referring to?

Scott.

Fire-Dragon-DoL
31 May 2012, 12:44 PM
Here you can see the 3 situations (before, after), notice that the renderer I'm using for the grid simply takes the value and put the "display" value on the grid instead of the "value" value.


http://dl.dropbox.com/u/762638/Files/Images/Screenshots/show_combobox_extjs_problem/part_1.png
http://dl.dropbox.com/u/762638/Files/Images/Screenshots/show_combobox_extjs_problem/part_2.png
http://dl.dropbox.com/u/762638/Files/Images/Screenshots/show_combobox_extjs_problem/part_3.png

Thanks for answering

Notice that you can use links to view screenshots in higher resolution.

P.S.
I'm trying to build a fix, however I can't find a single event that is fired when the combobox is "hidden" from the row editor (when the row editor disappear).
If you have any suggestion about it, I'll be graceful. Thanks

Fire-Dragon-DoL
1 Jun 2012, 6:25 AM
I'm almost done with the fix but I noticed a strange behaviour: when the component belongs to a form and the form is hidden/shown, the hide/show events of the combobox aren't fired.
I think this is a big problem, I need to hook to the parent and I can't know through the combobox if it belongs to a form or not (without additional code).

Is logical that when the combobox is shown, even if "someone else" is showing it, the event will be triggered.

Is this an intended behaviour or a bug?

Fire-Dragon-DoL
1 Jun 2012, 9:25 AM
I solved the problem by myself, sorry for bothering you with this.

The problem is that I'm using a store which uses a string as key and a string as value (for particular reason that I won't explain).

The grid didn't do the same, it was using an integer as key and a string as value.

Everything is ok until you load the combobox, infact combobox.setValue(6) is different from "6". The problem here was that the combobox understood 6 as number and chosen the correct field (I don't know how, because actually the store uses "6" and not 6), but something go wrong and set that number even in the textfield. If I write instead combobox.setValue("6") the display field is correctly shown in the textfield of the combobox, solving this issue.

By the way before I prefer to keep this type difference, I put a stupid code to solve this:


me.on('boxready', function(obj) {
obj.parentForm = obj.up('form');
obj.mon(obj.parentForm, 'show', function() {
if (obj.parentForm) {
if (obj.getValue() === null)
obj.inputEl.dom.value = "";
else
obj.setValue(obj.getValue().toString());
}
});
});

This simply ensure that when loading, the value sent to setValue is a string.
The problem is not present in the other direction: infact for grid all cells are actually "a string", for json too and for my server side language (ruby) it parses everything and understand that is a number.