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.

SelectItemByValue does not work when using the WebApiAdaptor

Thread ID:

Created:

Updated:

Platform:

Replies:

125549 Aug 24,2016 06:16 AM Aug 25,2016 08:00 AM JavaScript 1
loading
Tags: ejDropDownList
Mahindra Morar
Asked On August 24, 2016 06:16 AM

Hi,
I am developing a MVC5 web application and  populating a dropdownlist control  using the WebApiAdaptor to make a REST call. 
When I try and select an item it does not select it.

Below is the code I am using to populate and select a value in the dropdown control.

<script>
//Page loaded
    $(function ()
    {
        $("#drpStatus").ejDropDownList({
            dataSource: ej.DataManager({
                url: "GetStatusType",                
                adaptor: new ej.WebApiAdaptor()
            }),              
            fields: { text: "Name", value: "Code" }            
        }).data("ejDropDownList").selectItemByValue("HOLD");
 });
</script>

Are you able to tell me where I am going wrong?

Thanks
        

Keerthana Rajendran [Syncfusion]
Replied On August 25, 2016 08:00 AM

Hi Mahindra  
  
We had checked your code. We found that you have tried to select an item by value before data has been bound to dropdownlist. We suggest you to use this selectItemByValue in actionComplete event which will be triggered after data is bound to dropdownlist.   
  
  
   
<code>   
$(function() {   
        $("#drpStatus").ejDropDownList({   
            dataSource: ej.DataManager({   
                url: "/api/Orders",   
                adaptor: new ej.WebApiAdaptor()   
            }),   
            fields: {   
                text: "CustomerID",   
                value: "CustomerID"   
            },   
            actionCompletefunction(args)   
            {   
                var ddlobj = $("#drpStatus").data("ejDropDownList")   
                ddlobj.selectItemByValue("VICTE");   
            }   
                   
      })   
       
    });</code>   
  
We have prepared a sample please find in the below link.  
                                
Please let us know if any concern   


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.

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.

;