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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I refresh data from dropdownlist when it comes from ODataV4 Adapter?

Thread ID:

Created:

Updated:

Platform:

Replies:

145663 Jul 2,2019 09:21 PM UTC Jul 4,2019 05:21 AM UTC ASP.NET MVC - EJ 2 3
loading
Tags: DropDownList
Wender
Asked On July 2, 2019 09:21 PM UTC

I am trying to refresh the source with javascript but I can not do it,
 try several examples but apparently they have changed several things,

this is my control:
 @Html.EJS().DropDownListFor(model => model.Id_Insumo).Placeholder("Seleccione un articulo").DataSource(dataManger =>
                             dataManger.Url("/ControlGarantia/Articulos").Adaptor("ODataV4Adaptor").UpdateUrl("/ControlGarantia/Articulos").CrossDomain(true)).Fields(new Syncfusion.EJ2.DropDowns.DropDownListFieldSettings
                    {
                        Value = "value",
                        Text = "text"
                    }).Render()

Prince Oliver [Syncfusion]
Replied On July 3, 2019 01:33 PM UTC

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 


Wender
Replied On July 3, 2019 02:05 PM UTC

Thank you very much for the quick response, the solution worked.

Prince Oliver [Syncfusion]
Replied On July 4, 2019 05:21 AM UTC

Hi Wender, 

Most Welcome. We are glad to help you. Let us know if you need any further assistance on this. 

Regards, 
Prince 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon