- Home
- Forum
- ASP.NET MVC - EJ 2
- How can I refresh data from dropdownlist when it comes from ODataV4 Adapter?
How can I refresh data from dropdownlist when it comes from ODataV4 Adapter?
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()
SIGN IN To post a reply.
3 Replies
PO
Prince Oliver
Syncfusion Team
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
WS
Wender Schulze
July 3, 2019 02:05 PM UTC
Thank you very much for the quick response, the solution worked.
PO
Prince Oliver
Syncfusion Team
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
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
WS Wender Schulze
- Jul 2, 2019 09:21 PM UTC
- Jul 4, 2019 05:21 AM UTC