We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ejDropDownList - dataBound event not firing

Thread ID:

Created:

Updated:

Platform:

Replies:

131670 Jul 22,2017 03:56 PM UTC Jul 24,2017 11:38 AM UTC JavaScript 1
loading
Tags: ejDropDownList
Majd Alkassem
Asked On July 22, 2017 03:56 PM UTC

I am using the ejDropDownList with WebAPI data source, and I need to set the selected value once the dropdownlist is bound. I tried using the dataBound event, but it does seem to ever get called. The data does get populated in the list. Please see sample code below:

var pickerData = ej.DataManager({
url: "/api/Get/List",
crossDomain: true,
adaptor: new ej.WebApiAdaptor()
});

var pickerQuery = new ej.Query().addParams("id", id);
$("#ddl").ejDropDownList({
dataSource: pickerData,
query: pickerQuery,
fields: { text: "text", value: "value" },
targetID: "ddlList",
dataBound: function (args) {
debugger;
}
});

Keerthana Rajendran [Syncfusion]
Replied On July 24, 2017 11:38 AM UTC

Hi Majd, 
 
Thank you for contacting Syncfusion support 
 
We have prepared  a DropDownList sample with webAPI adaptor. dataBound event is fired when the items are bound to DropDownList. We have set selected value in DropDownList during dataBound event using value property. Please refer to the below code 
 
<div class="cols-sample-area"> 
    <input type="text" id="myList" /> 
</div> 
<script type="text/javascript"> 
     $(function () { 
        var dataManager = ej.DataManager({ 
            url: "../api/Orders", 
            adaptor: new ej.WebApiAdaptor(), 
            crossDomain: true, 
            query: ej.Query().select("CustomerID") 
        }); 
        $("#myList").ejDropDownList({ 
            dataSource: dataManager, 
            fields: { text: "CustomerID", value: "CustomerID" }, 
            dataBound: "ondatabound" 
        }); 
    }); 
    function ondatabound(args) { 
        var obj = $("#myList").data("ejDropDownList"); 
        obj.setModel({ value: args.data[2].CustomerID }); 
    } 
</script> 
 
We have prepared a sample for your reference. Please refer to the below given link 
We can also use actionComplete event of DropDownList for this requirement. Please refer to the below code 
$("#myList").ejDropDownList({ 
            dataSource: dataManager, 
            fields: { text: "CustomerID", value: "CustomerID" }, 
            actionComplete: "complete" 
        }); 
    }); 
    function complete(args) { 
        var obj = $("#myList").data("ejDropDownList"); 
        obj.setModel({ value: args.e.result[2].CustomerID }); 
    } 
 
If the issue persists kindly get back to us by modifying the above sample to reproduce the issue along with the product version used in your project so that we can proceed further. 
Regards, 
Keerthana. 
 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;