PDA

View Full Version : Combo with same values but different text



MartinL
21 Sep 2010, 10:46 PM
Maybe someone can help me to solve my problem? I made a dynamic combo with 4 different selections but it could be that the values of different selections are the same. So it selects me the first Text with this value. I am thinking about a setIndex() or something like this but can not find this.

sample:
Text Value
Modul1 20
Modul2 30
Modul3 20
Modul4 40

Then Modul1 is shown nevertheless I selected Modul3.

Animal
21 Sep 2010, 11:31 PM
The value is what you are selecting and what you are submitting.

So that Store is just invalid. If you select value "20" you want unique key "20". Otherwise what's the point of selecting the value if it doesn't tell you what you are selecting?

MartinL
21 Sep 2010, 11:39 PM
I am developing a phone-administration tools and the user is able to select the Modul he wants to configure. Maybe he has a basic phone plus 2 additional 20 key Moduls. It also works with selecting then the right Modul (example Modul 2) to select the right store but he sees in his combo always Modul 1 because it is the first one with 20 keys.

Animal
21 Sep 2010, 11:46 PM
So what do you want to SUBMIT to the server? The string "Modul 3"?

MartinL
21 Sep 2010, 11:51 PM
Just the value of Modul 3. But thats still working. I just want the user show the right selection in the combo - nothing more. If he selects Modul 2 , I show Modul 2, if he selects Modul 3, I show him Modul 3. This works all the time with a combo, but not if I have 2 or more selections with the same value

Animal
21 Sep 2010, 11:53 PM
So then, how does the SERVER know whether "20" means "Modul1" or "Modul3"?

MartinL
22 Sep 2010, 12:01 AM
I do this all in the UI. Therefore I have:

var Tastenanzahl = ComboModul.getValue();
var ComboModul = Ext.getCmp('myModulCombo');
var record = ComboModul.getStore().getAt(i);
var Modul = record.get('Modul');

and I can now check:

if (i=2 && Modul == "Modul2") ...

MartinL
22 Sep 2010, 12:31 AM
O.K. I found the solution, nevertheless thanks for your help Animal

var ComboModul = Ext.getCmp('myModulCombo');
var record = ComboModul.getStore().getAt(i); // Gets the record at that index
var Modul = record.get('Modul'); // Returns the text of the Combo
ComboModul.setValue(""+Modul+"");

Thats all! ;-)