Dynamically add a list box item

Hello.

I have a list box that is bound to a table, and now I need to add values to the list box.

I can add a new item to the list of hard-coding a value, such as:

arrayData.addItem ({'label': 'test2', 'data': '99'});

It works very well. But the problem is that I do not know what will be the values,
so I need a way ot add value dynamically using variables.

I tried:

var strLabel:String = 'Some Text';
var strData:String = "99";
var newItem:Object = "{"label":" "}" + strLabel + "', 'data':'" + strData + "'";}

And then add it to the table:

arrayData.addItem (newItem);

But what appears in the list box is:

{'label': 'Some Label', 'data': '99'}

I tried all the variations I could think. What is the correct syntax to do this?

Thank you








The syntax is:

var strLabel:String = 'Some Text';
var strData:String = "99";
var newItem:Object = {label: strLabel data: strData};
arrayData.addItem (newItem);

Tags: Flex

Similar Questions

  • List box items, once again

    Need help with the items in drop-down list again.  I have a script that gets the text within the same form field values and displays the values as items in the drop-down list box.  It works perfectly; However, when I select an item in the list, the item does not stick/show when selected and the field is empty.

    Script is below:

    var l = this.getField ("T1T1 name");
    Value1 = this.getField("Name1").value;
    value2 = this.getField("Name2").value;
    value3 = this.getField("Name3").value;
    Value4 = this.getField("Name4").value;
    Value5 = this.getField("Name5").value;
    Value6 = this.getField("Name6").value;
    valeur7 = this.getField("Name7").value;
    value8 = this.getField("Name8").value;
    value9 = this.getField("Name9").value;
    value10 = this.getField("Name10").value;
    l.setItems (["", value1, value2, value3, value4, Value5, Value6, valeur7, value8, value9, value10,]);

    "T1T1 name" is the name of combo box

    When I take the first line of the script out, the element values stick/show when selected and I go to the next field, but they do not update when additional values are entered in the fields "name".

    Any help would be greatly appreciated.


    Thank you

    That's the problem. I suggest setting up a document level function that you call of each text field Validate event. the script would add only an element if the text field is not empty. The script will need to be changed a little. Post again if you get stuck.

  • Problems of dynamic drop-down list box

    Hello

    I have a requirement for a list dynamic downdown.

    I use javascript itself to fill the 2 text fields in the drop-down list.  I need the list/menu area drop down to be able to have options to input from the user and the drop-down list. I selected the "user entered - optional" compared to the setting but does not seem to work.

    The drop has used names and if a new employee joined this company and I do not know the end user can enter the name of the employee in the field.

    I have attached a pdf file version.

    Any ideas or help would be great.

    See you soon.

    Hello. All you have to do is check the box "Enable custom text entry". You can find the object box > cell phone

  • set the values for the list box item

    Hi all

    How you set values for a checkbox element including more of 2 values.
    You retrieve data from a table, so when you query the table, you get several lines accordingly.
    I think it's something for the table_to_string function, but I don't really know how to use it with bind variables
    Can someone help me?

    Thanks in advance,
    Cleo

    Set the Source of the item box:

    Type of source
    SQL query (separated by semicolons return value)

    Source of value or expression

    /* Something like this, according to your table and columns */
    select course_id
    from student_courses
    where student_id = :p1_student_id
    
  • A drop-down list box, two text boxes

    Hi all, I feel a bit silly to ask what she should be very simple, right? I have the a combo, the solution box a text down pat. For example when the user select name of the staff member in the drop down menu, it fills the phone number of this person in Textbox1.

    I would like to add to this so that when a user selects (and here I use false details) "Bob," he filled before his phone number in Textbox1 and "[email protected]" in Textbox2 simultaneously. Simply impossible to find the solution of anywhere.

    So far, I have used the code next (on the net) in the scripts of strike of the custom from the drop-down list box, but how I lay on it?

    (function () {}

    Do nothing if it is committed
    If (event.willCommit) return;

    Set up a table to hold the various paragraphs of the text
    var aQuotes = [];

    Fill the table with the text of paragraph
    aQuotes [0] = "bob phone"
    aQuotes [1] = 'sarah phone'
    aQuotes [2] = "phone linda".
    aQuotes [3] = "phone jerry."
    aQuotes [4] = "phone of mary".
    aQuotes [5] = 'phone jessie. "

    Get the selected item, which is the value of exports of the selected drop-down list box item
    var point = event.changeEx

    Display the text corresponding to the selected item in the text field
    getField("ITC_Phone").value is aQuotes [point];.

    })();

    Bravo guys.

    Like this:

    Custom script from typo to the drop-down list box (dropdown)

    (function () {}

    Do nothing if it is committed

    If (event.willCommit) return;

    Set up a table to hold the various paragraphs of the text

    var aQuotes = [];

    Complete the tables table of telephone and e-mail addresses

    aQuotes [0] = ['phone of bob', "[email protected]" ""];

    aQuotes [1] = ["sarah phone", "[email protected]" ""];

    aQuotes [2] = ["phone linda", "[email protected]" ""];

    aQuotes [3] = ['phone jerry', "[email protected]" ""];

    aQuotes [4] = ['phone mary', "[email protected]" ""];

    aQuotes [5] = ["phone jessie", "[email protected]" ""];

    Get the selected item, which is the value of exports of the selected drop-down list box item

    var point = event.changeEx;

    Display the text corresponding to the selected item in the text field

    getField("ITC_Phone").value = aQuotes [item] [0];

    getField("ITC_Email").value = aQuotes [item] [1];

    })();

    This code assumes that the value of exports of the items in drop-down list box is 0, 1, 2, 3...

    If there is much more that the aQuotes table should really be defiined in a JavaScript file at the level of the document if you are concerned about performance and maintainability.

  • List box data selected

    I have a combo box list called class_cb, I am using the drop-down list box in a mathematical formula.
    I try to set that if data from combo box selected active = 1 then a text box = account number, if data = 2 then...
    I can get flash to acknowledge change can't get instruction
    "If some data box combo = zone 1 then text = 5" to work, the default values of the first value text box and changing the
    drop-down list box item and press on calculate does not change the value of the text box.

    Any help would be appreciated, thanks

    //************************************************
    DROP-DOWN LIST BOX
    //************************************************
    Add items to the list.
    class_cb. AddItem ({data: 1, label: "Normal"});
    class_cb. AddItem ({data: 2, label: "Free"});
    class_cb. AddItem ({data: 3, label: "Close & interference"});

    Update on the change listener object
    //
    Create a listener object.
    var cbListener:Object = new Object();
    Assign the function of listener object.
    cbListener.change = {function (event_obj:Object)}
    trace ("value is replaced by:" + event_obj.target.selectedItem.data);
    };
    Add the listener.
    class_cb.addEventListener ("change", cbListener);

    //************************************************
    CALCULATE
    //************************************************
    shaft_ta. Text = "null";

    Calculate_btn release
    Mathematical functions
    calculate_btn.onRelease = function() {}
    If the drop-down list box data = no. then change the label
    If (class_cb.selectedItem.data = 1) {}
    shaft_ta. Text = "6";
    } else {}
    If (class_cb.target.selectedItem.data = 2) {}
    shaft_ta. Text = "7";
    } else {}
    If (class_cb.selectedItem.data = 3) {}
    shaft_ta. Text = "9";
    }
    }
    }
    }

    Thought that he, just modified the trace command to change the text box.

  • Modification of the properties-type def drop-down list box

    I have a group of 32 cases of a def type. The def type contains several different types of control. What I have to do is to change the properties of the list box for each of the type defs. Normally, I would create an array of references to change the properties for each of the type defs, but when I try this I can not access the properties of string [] for combo box selections. The only way I found to fix it is to create a reference for each individual drop-down list box item. It is labour, since I'll have 32 elements. Is there a way to beeter to do this? The first screenshot shows the issui I'll have, not being able to change the properties of specific elements within each of the def type at runtime through a control [] array. The second screenshot shows the only solution I've found so far, which is not very practical.

    You will need to set up (for a more specific class) control to a type of combo box for the particular control [] index that has the combobox control if you want to access the drop-down list.

    You can also access the combobox in a cluster based directly, rigth click on the control reference and a link to the element cluster directly.

    The last option is to make the strictt of typdef will fill all instances with the channel list [] given that it is a strict property.

    the approach is based on the weather, you plan on changing the list during execution.

  • dynamically add or remove items from the context menu?

    Hello

    Is there a (safe) way to dynamically add or remove items

    a context menu for an effect plugin type parameter?

    Thank you.

    N ° parameters, including pop-up lists, filling occurs before the effect is applied to a sequence.

  • How to change the items in a drop-down list box that is part of an array of clusters

    Hello

    In the attached vi, I have an array of clusters and each cluster contains two drop-down list boxes. How can I edit the items in the drop-down list box 1 for all elements in the array? (All elements of list box 1 has the same elements.)

    By way of illustration, I have also included the case of trivila, for example, edit the items in a separate drop-down list box that is is not part of an array of clusters (combo box 3). Please notify. Thank you.

    Peter

    Right click on the drop-down list box and select Create-> Node-> String() property. Place it on the block diagram. Change to write (right click) and then feed him an array of strings.

  • Change the number of items in the drop-down list box when running

    I'm trying to change the number of items in one of my boxes of comobo.

    I have been through the help and this forum and have the values to within the drop-down list box change very well, but in a scenario, I want to go to three options for 2. And according to other choices to 3.

    I guess I have to use a property node but I can't understand that one.

    You can use the method to reset to zero (using an invoke node) before setting the [Strings] (after setting the value by default an empty array) or create an Xcontrol (you can see examples of LabVIEW for xcontrol).

    Ben64

  • Can anyone help please if a drop-down list box with this dpdCategory.Items.Insert (0, "user")?

    can someone please help if a drop-down list box with this dpdCategory.Items.Insert (0, "user"); If I choose the user then after clicking the button, it will redirect to this page & also, others using if else statement

    Please ask this question in one of the Windows Apps development forums:

    http://social.msdn.Microsoft.com/forums/en-us/category/windowsapps

  • How to add a destination folder in the drop-down list box "send to" in Windows XP?

    One of my disks in CD does not work, so I want to add the DVD drive in the drop-down list box... I can't remember how.

    Hello

    This article can help...

    http://support.Microsoft.com/kb/310270

    Tricky

  • How to manually remove items in the Add/REMOVE list

    I uninstalled a particular program, but it still appears in the Add/REMOVE list. It is still also in the folder programs. How can I manually remove this program in the Add/REMOVE list?

    Hi Sweetpence51,

    1. are you able to uninstall properly the other programs on the computer?

    2. you use Windows vista or Windows XP operating system?

    Method 1

    First of all, make sure that you have followed the right instructions to remove the program from the computer.

    If the program does not uninstall completely the first time, sometimes running the uninstall program a second time will succeed.

    Troubleshoot installing or uninstalling programs

    http://Windows.Microsoft.com/en-us/Windows-Vista/Troubleshoot-installing-or-uninstalling-programs

     

    Method 2

    If you are unable to remove the program from the Add/Remove programs then you need to remove the keys associated with the program from the registry.

    Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, see the link below.

    Back up the registry

    http://Windows.Microsoft.com/en-us/Windows-Vista/back-up-the-registry

    Note: In the procedure below, replace Add/Remove programs and features if you are using the Windows vista operating system.

    (a) click Start and in the search box, type regedt32, and then click OK.

    (b) in the registry editor, find the following registry key:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall

    (c) in the left pane, click the Uninstall registry key, and then click export on the file menu.

    (d) in the export registry file dialog box that appears, click desktop in the list record in , type Uninstall in the file name box, and then click Save.

    (e) each key listed under Uninstall in the left pane of Registry Editor represents a program that is displayed in the list of currently installed programs in the add tool / remove programs. To determine which program that represents each key, click the key and discovers the following values in the details on the right pane:

    DisplayName: Data of the value of the DisplayName key is the name listed in Add / Remove programs.
    - and -
    UninstallString: The value of the UninstallString key data the program used to uninstall the program.

    (f) after you identify the registry key that represents the program that you removed but which is still displayed in the list of currently installed programs , add or remove programs, right-click the key in the left pane of the registry editor window, and then clickRemove.

    (g) click Yes in response to the message "are you sure you want to delete this key and all of its subkeys?

    (h) on the file menu, click Exit to quit the registry editor.

    (i) click Start, click Control Panel, and then click on Add / Remove Programs.
    In the currently installed programs list, verify that the program whose registry key you deleted is no longer listed.

    (j) do one of the following:

    1. If the program list is not correct in Add / Remove Programs, double-click the file Uninstall.reg that you saved on your desktop in step 5 to restore the original list of programs in the registry.
    -or-

    2. If the program list is correct in Add / Remove Programs, right-click the Uninstall.reg file on your desktop and then click Remove.

    How to manually remove programs from the add tool / remove programs

    http://support.Microsoft.com/kb/314481

    Note: The preceding Microsoft article also applies to Windows vista operating systems.

    I hope this helps!

    Halima S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • How to dynamically add an Option in the drop-down list?

    I have this code:

    {Drop-down list

    ID: list

    Title: 'list '.

    onCreationCompleted: {}

    opion var = new Option();

    opion. Text = "Hello";
    opion. Value = 4;

    List.Add (opion);

    }

    }

    After the launch of the application, the list is empty.

    Why my code does not work?

    It is easy to dynamically add options

    first add this to your attachedObjects:

    ComponentDefinition {
                id: optionDefinition
                Option {
                }
            }
    

    then do something like this

    var newOption = optionDefinition.createObject()
                newOption.text = ...
                newOption.value = ...
                newOption.description = ...
                newOption.selected = ....
                yourDropDown.add(newOption)
    
  • How we can dynamically add or remove action from the popup menu in qml item

    Hi all

    I want to just dynamically add or remove action from the actionset item in the contextual menu especially in qml.

    Thanks in advance.

    Kind regards

    Ankur

    You can do so by joining the actionitem as attachedObjects. Once the page is complete (signal onCreationCompleted), you can add it to the page using addAction()

    To remove, you simply delete the page using removeAction()

    https://developer.BlackBerry.com/Cascades/reference/bb__cascades__page.html

Maybe you are looking for