jQWidgets Forums

jQuery UI Widgets Forums Lists ComboBox jqxComboBox ‘getItemByValue’ not working for me

This topic contains 2 replies, has 2 voices, and was last updated by  Stefan Mizzi 11 years, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • Stefan Mizzi
    Member

    Hi 🙂

    I started using the awesome jqWidgets and came across a small issue, where I am sure I’m doing something wrong. Below is my code:

    The url calls an asp.net web service where it gets a list of objects with ID and DriverName.

    My problem is the last line…the object “item” remains undefined. What am I doing wrong please? Joe Bloggs exists in the list. I’m using the latest jqWidgets version.

    Thank you!!!

    var sourceDriver = {

    type: “GET”,
    datatype: “json”,
    datafields: [{ name: ‘ID’ }, { name: ‘DriverName’ }],
    url: urlGetDrivers,
    cache: false,
    root: ‘dataDriver’
    };

    //Preparing the data for use
    var dataAdapterDriver = new $.jqx.dataAdapter(sourceDriver, { contentType: ‘application/json; charset=utf-8’,
    downloadComplete: function (dataDriver, textStatus, jqXHR) {
    return dataDriver.d;
    }
    }
    );

    // Create jqxComboDriver
    $(“#jqxComboDriver”).jqxComboBox({ source: dataAdapterDriver, displayMember: “DriverName”, valueMember: “ID”, selectedIndex: 0, width: ‘200px’, height: ’25px’, theme: ‘energyblue’ });

    var item = $(“#jqxComboYou”).jqxComboBox(‘getItemByValue’, ‘Joe Bloggs’);

     


    Peter Stoev
    Keymaster

    Hi,

    That code will not work because the binding is “async” and at the point you call “var item = $(“#jqxComboYou”).jqxComboBox(‘getItemByValue’, ‘Joe Bloggs’);”, the widget will still not be populated with data. You should call that line once the binding operation is completed.

    Best Regards,
    Peter Stoev

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


    Stefan Mizzi
    Member

    Thank you Peter!

    Cheers
    Stefan

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

You must be logged in to reply to this topic.