jQWidgets Forums

jQuery UI Widgets Forums Lists ComboBox Wrong selectedItem after filtering

This topic contains 4 replies, has 3 voices, and was last updated by  Marc 12 years, 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • Wrong selectedItem after filtering #4627

    Hi,

    sorry for my bad english. ;o)

    I’m using jqxComboBox in version 2.2.
    Basing on your example code I tried out your jqxComboBox.

    I’ve found the following problem:

    I fill the combobox with your example data. I’ve extended the ComboBox with the parameter ‘valueMember’ and assigned a variable value.
    If I select an item from ComboBox I use this value for other database queries. This works fine only if I use the dropdown list. If I use the autocomplete function and type the first letters to filter the dropdown-list and select an item from ComboBox, I get wrong values.

    If your try the following example you get the right values if you use ComboBox without using autocomplete-filtering (If you click ‘Unstoppable’ you get the right value ‘Unstoppable’). In case you type ‘U’ to filter the dropdown-list and click now on ‘Unstoppable’ you get the (wrong) value ‘End Game’. If you now open the ComboBox-dropdown list, the item ‘End Game’ is selected.

    How I can get the right value after autocomplete-filtering?

    Regards.

    Example code:


    var source = new Array();
    for (i = 0; i < 10; i++) {
    var movie = 'avatar.png';
    var title = 'Avatar';
    var year = 2009;
    switch (i) {
    case 1:
    title = 'End Game';
    break;
    case 2:
    title = 'Priest';
    break;
    case 3:
    title = 'Unknown';
    break;
    case 4:
    title = 'Unstoppable';
    break;
    case 5:
    title = 'Twilight';
    break;
    case 6:
    title = 'Kung Fu Panda';
    break;
    case 7:
    title = 'Knockout';
    break;
    case 8:
    title = 'The Plane';
    break;
    case 9:
    title = 'Big Daddy';
    break;
    }
    source[i] = {name: title, id: i };
    }
    $("#jqxcombobox").jqxComboBox(
    {
    source: source,
    autocomplete: true,
    searchMode: 'containsignorecase',
    theme: 'classic',
    width: 350,
    height: 25,
    displayMember: 'name',
    valueMember: 'id'
    });
    $('#jqxcombobox').bind('select', function (event) { // Some code here.
    var args = event.args;
    var item = $('#jqxcombobox').jqxComboBox('getItem', args.index);
    alert('Selected: ' + item.label);
    });

    Wrong selectedItem after filtering #4629

    Peter Stoev
    Keymaster

    The reported issue is regarding the ‘getItem’ method of the jqxListBox widget and we confirm it.

    The workaround for getting the correct item is to use an array called ‘visibleItems’ array.

    Example:

    var item = $('#jqxcombobox').jqxComboBox('listBox').visibleItems[args.index];

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Wrong selectedItem after filtering #14071

    Marc
    Participant

    +1 on this issue.

    ‘getItem’ and ‘getSelectedItem’ still do not work when autoComplete is enabled. Will this be fixed in a future release or the documentation updated to provide this work-around?

    Thanks,

    Marc

    Wrong selectedItem after filtering #14072

    Peter Stoev
    Keymaster

    Hi Marc,

    The getItem and getSelectedItem methods use the ‘items’ collection and return an item from the ‘items’ collection based on a specific index. For getting a visible item, use the getVisibleItem method as it is supposed to work only with items that are visible or you can use the code which was already provided.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Wrong selectedItem after filtering #14075

    Marc
    Participant

    Thanks Peter – I don’t think the ‘getVisibleItem’ method is documented for jqxComboBox.

    Marc

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

You must be logged in to reply to this topic.