jQWidgets Forums

jQuery UI Widgets Forums Lists DropDownList DropDownList select item not working

This topic contains 3 replies, has 2 voices, and was last updated by  ivailo 8 years, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • DropDownList select item not working #89173

    tbrocker
    Participant

    Hi,

    I am attempting to pre-select a value in a drop down list box, and cant get it to work (select item ‘Medical’). The drop down works, has all the values including ‘Medical’ and after I select I see the correct value, but I can not get it to pre-select. Please see the code below.

    var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘mtEventCodeName’, type: ‘string’}
    ],
    url: ‘data_event_code.php’,
    cache: false
    };

    var dataAdapter = new $.jqx.dataAdapter(source);

    $(“#jqxDropDownList”).jqxDropDownList(
    {
    source: dataAdapter,
    theme: ‘classic’,
    width: 150,
    height: 25,
    displayMember: ‘mtEventCodeName’,
    valueMember: ‘mtEventCodeName’
    });
    $(“#jqxDropDownList”).jqxDropDownList(‘selectItem’, ‘Medical’);

    $(‘#jqxDropDownList’).bind(‘select’, function (event) {
    var args = event.args;
    var item = $(‘#jqxDropDownList’).jqxDropDownList(‘getItem’, args.index);
    document.getElementById(‘mteventcode’).value=item.label ;
    });

    Thank you,

    DropDownList select item not working #89185

    ivailo
    Participant

    Hi tbrocker,

    You have to bind to the event before the “preselection” if you want to get the item.
    Please refer to this DropDownList demo.

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com

    DropDownList select item not working #89204

    tbrocker
    Participant

    Yes, I see that I can leverage the open event then the pre-selection will work. In this case, the user would be returning to the form and pulling up an existing transaction. In that case I would like the drop-down to show the selection without opening the drop-down list box. How would you recommend I approach the pre-selection in that case?

    Thank you,

    DropDownList select item not working #89222

    ivailo
    Participant

    Hi tbrocker,

    You also can use selectedIndex property.
    For example selectedIndex: 1

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.