Hi Wender,
Thank you for contacting us.
To refresh the data from a OData source, you need to manually rebind the data to the control. Use the datamanager to the fetch the updated source and bind it the dataSource property. Kindly refer to the following code.
@Html.EJS().DropDownListFor(model => model.Value).Placeholder("Select a game").Width("300").PopupHeight("200px").DataSource(obj =>
obj.Url("https://services.odata.org/V4/Northwind/Northwind.svc/").CrossDomain(true).Adaptor("ODataV4Adaptor")).Fields(new DropDownListFieldSettings
{
Text = "City",
Value = "City"
}).Query((string)ViewBag.query).AllowFiltering(true).Render()
<button onclick="btnClick()">Refresh data</button>
<script>
function btnClick() {
var datamanager = new ej.data.DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/',
adaptor: new ej.data.ODataV4Adaptor(),
crossDomain: true
});
var ddl = document.getElementById("Value").ej2_instances[0];
ddl.datasource = datamanager;
ddl.query = new ej.data.Query().from('Employees').select(['City']).take(10);
ddl.dataBind();
}
</script> |
We have attached the example for your reference, please find it in the following location:
Let us know if you need any further assistance on this.
Regards,
Prince