jQWidgets Forums

jQuery UI Widgets Forums Lists DropDownList bindingComplete not firing

This topic contains 1 reply, has 2 voices, and was last updated by  Dimitar 10 years, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • bindingComplete not firing #57548

    joepacelli
    Participant

    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?

    bindingComplete not firing #57583

    Dimitar
    Participant

    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,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.