jQuery UI Widgets › Forums › General Discussions › Lists › DropDownList › bindingComplete not firing
Tagged: before, bindingcomplete, DropDownList, initialization, jqxDropDownList, not firing
This topic contains 1 reply, has 2 voices, and was last updated by Dimitar 11 years, 4 months ago.
-
Author
-
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?
Hello joepacelli,
You have to bind to the bindingComplete event before the initialization of the jqxDropDownList, not after that. That is because, when you bind to the event after the widget’s initialization, the binding is already completed.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.