I load a dynamic list of animals from server, according to the selected animal owner dropdown. And then I need to select the corresponding animal using the animal_id stored on appointment
my dropDown:
$("#animal").jqxDropDownList({
source: animalAdapter,
displayMember: "name",
valueMember: "animal_id",
width: "345px",
height: "20px",
filterable: true,
filterPlaceHolder: "Buscar",
placeHolder:"-- Novo Animal --"
});
my source and adapter:
var animal = {
datatype:'json',
datafields:[
{name:'name',type:'string'},
{name:'animal_id',type:'int'}
],
url:'list_animals',
async:false
};
var animalAdapter = new $.jqx.dataAdapter(animal,{
formatData: function(data) {
data.owner_id = getSelectedOwner();
return data;
},
});
my selectItem code:
animalAdapter.dataBind();
$("#animal").jqxDropDownList('selectIndex', appointmentData.animal_id );
my server data response:
[{animal_id: 9773, name: "Nina"}]