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.