jQuery UI Widgets Forums Lists ComboBox ComboBox Question passing ID

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • ComboBox Question passing ID #47644

    DavidSimmons
    Participant

    Can someone please help me with a ComboBox question. I need to have a ComboBox with a list of names and have this working but I need to pass a CompanyID to ComboBox source. I am trying to pass it like the following but is not working. I have tested the setting my JSON to a fix ID and the comboBox works correctly.

    Can please show how to pass the ID in this case…

    var theme = “custom”;

    var Company = new Object();
    Company.ID = ‘2429’;

    var source = {
    datatype: “json”,
    datafields: [
    { name: ‘ID’ },
    { name: ‘Contact’ }
    ],
    url: “../JSON/ContactJSON.php”,
    async: false,
    data: Company
    };

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

    // Create a jqxComboBox
    $(“#jqxComboBox”).jqxComboBox({source: dataAdapter, displayMember: “Contact”, valueMember: “ID”, multiSelect: true, width: 350, height: 25, theme: theme });
    $(“#jqxComboBox”).jqxComboBox(‘selectItem’, ‘United States’);
    $(“#jqxComboBox”).jqxComboBox(‘selectItem’, ‘Germany’);
    // trigger selection changes.
    $(“#jqxComboBox”).on(‘change’, function (event) {
    var items = $(“#jqxComboBox”).jqxComboBox(‘getSelectedItems’);
    var selectedItems = “Selected Items: “;
    $.each(items, function (index) {
    selectedItems += this.label;
    if (items.length – 1 != index) {
    selectedItems += “, “;
    }
    });
    $(“#selectionlog”).text(selectedItems);
    });

    ComboBox Question passing ID #47667

    Dimitar
    Participant

    Hello DavidSimmons,

    Please clarify your question.

    Do you want a third datafield in the combobox source? Note that jqxComboBox supports only two values – displayMember and valueMember.

    Or do you have an issue with the “ID” valueMember?

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    ComboBox Question passing ID #47727

    DavidSimmons
    Participant

    Here is my working example but I would assume by your documentation that a property of data send to the server on the getting the source.

    var Company = new Object();
    Company.Company = ‘2429’;

    var source = {
    datatype: “json”,
    datafields: [
    { name: ‘ID’ },
    { name: ‘Contact’ }
    ],
    url: “../JSON/ContactJSON.php?Company=”+Company,
    async: false
    };

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

    // Create a jqxComboBox
    $(“#jqxComboBox”).jqxComboBox({source: dataAdapter, displayMember: “Contact”, valueMember: “ID”, multiSelect: true, width: 350, height: 25, theme: theme });
    $(“#jqxComboBox”).jqxComboBox(‘selectItem’, ‘United States’);
    $(“#jqxComboBox”).jqxComboBox(‘selectItem’, ‘Germany’);
    // trigger selection changes.
    $(“#jqxComboBox”).on(‘change’, function (event) {
    var items = $(“#jqxComboBox”).jqxComboBox(‘getSelectedItems’);
    var selectedItems = “Selected Items: “;
    $.each(items, function (index) {
    selectedItems += this.label;
    if (items.length – 1 != index) {
    selectedItems += “, “;
    }
    });
    $(“#selectionlog”).text(selectedItems);
    });

    ComboBox Question passing ID #47779

    Dimitar
    Participant

    Hi DavidSimmons,

    Data can be sent to the server, as shown in the demo Remote Search, in which the data source property is set.

    Best Regards,
    Dimitar

    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.