I’m loading a DropDownList from my C# MVC model
// Send up the Data Sources
var mydata = '@Html.Raw(Json.Encode(@Model.Organizations))';
var facilitySource =
{
dataType: "json",
dataFields: [
{ name: 'ShortName', type: 'string' },
{ name: 'OrgNbr', type: 'string' }
],
async: false,
localdata: mydata
};
//Sent up the Data Adapters
var facilityAdapter = new $.jqx.dataAdapter(facilitySource, {
loadComplete: function() {
alert('Loaded');
}
});
$("#orgs").jqxDropDownList(
{
theme: 'energyblue',
source: facilityAdapter,
width: 300,
height: 25,
promptText: "Select org...",
displayMember: 'ShortName',
valueMember: 'OrgNbr'
});
$("#orgs").on('bindingComplete', function (event) {
alert('Binding Complete');
});
After the data is loaded into the Dropdownlist I need to select the default item based on the valueMember.
The loaded event fires but the data is not in the DropdownList yet so I can’t set it here
The bindingComplete event never fires.
I had this code in bindingComplete. This was working fine when I was not using the localdata
and returning a jsonResult.
if (orgNbr != "") {
var item = $("#orgs").jqxDropDownList('getItemByValue', orgNbr);
$("#orgs").jqxDropDownList('selectIndex', item.index);
How do I set the default value in the DropDownList if bindingComplete never fires?