jQWidgets Forums
jQuery UI Widgets › Forums › Getting Started › jqxComboBox with getSelectedItems selects the wrong item
This topic contains 1 reply, has 2 voices, and was last updated by svetoslav_borislavov 2 years, 4 months ago.
-
Author
-
Hi, I fill a jqxComboBox with custom data. The valueMember is not unique in my case. Sometimes there are two the same names. However, they differ in the UI through a custom renderer, and one of the datafields holds a version number. This works great, but when I use getSelectedItems to obtain the version, it is always the highest version.
var source = { datatype: "json", datafields: [ { name: 'testId' }, { name: 'version' }, { name: 'shortName' }, { name: 'description' }, { name: 'index' }, { name: 'credit' }, { name: 'creditLicence' } ], url: url, async: true, data: { "languageId": languageId, "all": all } }; var data = []; var dataAdapter = new $.jqx.dataAdapter(source, { loadComplete: function (records) { console.log("get tests length :" + records.length); }, beforeLoadComplete: function (records) { data = records; return records; } } ); $("#jqxComboTest").jqxComboBox({ selectedIndex: 0, theme: 'energyblue', searchMode: 'containsignorecase', multiSelect: true, autoOpen: true, source: dataAdapter, displayMember: 'shortName', valueMember: 'testId', placeHolder: placeHolder, autoComplete: true, dropDownWidth: ddWidth, dropDownHorizontalAlignment: ddAlign, dropDownHeight: 550, width: width, height: 30, renderer: function (index) { if (data.length === 0) return ""; var datarecord = data[index]; var table = '<table><tr><td style="width: 120px;">' + datarecord.shortName + '</td><td>' + datarecord.description + '</td></tr></table>'; return table; }
The selection is retrieved as follows:
var items = $("#jqxComboTest").jqxComboBox('getSelectedItems'); $.each(items, function (index) { var testId = items[index].value; var version = items[index].originalItem.version testIds.push(testId); versions.push(version); });
In my case I have a testId with the same content, but 2 versions. The highest version is always returned, irrespective of the one selected in the UI.
Is there another way to retrieve the proper version datafield?
thx Pieter
Hi,
You cannot have same values, each value should be unique.
Consider having different data field for the equal valuesBest regards,
Svetoslav BorislavovjQWidgets Team
https://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.