:: Forum >> Version 2 >>

Set Combo selected item by other control

More information on this topic is available in the documentation section: /general.intro/.

I am evaluating AW and am trying to find the answer to a question listed in the thread "Set Combo selected item by other control" as already listed in the Support Forum. The last question in the thread which was posted by ASJ on Monday, May 15, 2006 is also what I am trying to figure out how to do. At the bottom of this thread there is stated "This topic is archived".

Does the "This topic is archived" in the Support Forum mean that I have to look someplace else within the site in order to find the answer I am looking for ?? If Yes - where please ??

My problem is:

I fill the grid with data from a MySQL fetch on the left side of the screen and show a form on the right side of the screen with the data from the selected row of the grid on left side. I will be needing to do this because a lot of the record data cannot be displayed in the grid since there are just too many fields.

One of the fields in the form on the right side is a combo box. My problem is being able to select the combo box item that is associated with the data from my MySQL database in order that it appears immediately in the combo box and thus identifying the actual record content when the form is initialized.

Maybe - in order to explain my question more simply:
Step 1. I have an array with 10 items.
Step 2. I fill a combo with the array.
Step 3. Now I want to select the 3rd item in the combo so that the combo will display the 3rd item of the array when refreshed.

Step 1 & 2 I have already done with no problem. It is with Step 3 that I cannot find the answer.

Can anyone give me a clue ???

I am using:

var combo = new AW.UI.Combo;
combo.setId("combo1");
combo.setItemText(myCashAccountArray);
combo.setItemCount(<?echo $cashAccountCount;?>);
// make input box readonly
combo.getContent('box/text').setAttribute('readonly', true);
// fix for 'contentEditable' attribute
combo.onControlEditStarted = function() {
this.getContent("box/text").element().contentEditable = false;
}
combo.refresh();








George Leonard
Monday, September 17, 2007
You can use setSelectedItems() method -

combo.setSelectedItems([3]); // select item-3 in the dropdown list
combo.setControlText(combo.getItemText(3)); // update combo text
Alex (ActiveWidgets)
Tuesday, September 18, 2007
That did it perfectly - thanks very much Alex.

AW is looking good for my evaluation. Have still a lot to do since I am converting one of my small PHP/MySQL projects to AW for the evaluation.

Thanks again for your help.
George Leonard
Tuesday, September 18, 2007



This topic is archived.

Back to /general.intro/

Documentation:

Forum search