With the following code it will not set the initial value of the drop down list. The list does not get anything selected.
I try to set the selected Id to 19 which is a valid value. I notice when I debug that the data adapter has not loaded any records at that point. Does it auto load when I try to set the list val or do I need to force it to load the records first?
After this the drop down list is functioning and showing all records – it just does not get the initial value selected – please help.
var ClassesDataSource =
{
dataType: “json”,
root: “Data”,
dataFields: [
{ name: ‘Id’, type: ‘number’ },
{ name: ‘Description’, type: ‘string’ }
],
id: ‘Id’,
url: ‘/Attributes/GetAttributeClasses’
}
var ClassesDataAdapter = new $.jqx.dataAdapter(ClassesDataSource,
{
loadError: function (jqXHR, status, error) {
alert(“There was an error please contact support”);
},
}
);
$(“#cmb”).jqxDropDownList({
autoDropDownHeight: true,
source: ClassesDataAdapter,
valueMember: ‘Id’,
displayMember: ‘Description’
});
// Try to set the selected value. This does not work – nothing is selected.
// 19 is an existing Id in the list.
$(“#cmb”).jqxDropDownList(‘val’, ’19’);