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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Bind drop down Json result

Thread ID:

Created:

Updated:

Platform:

Replies:

140895 Nov 13,2018 10:50 AM UTC Nov 15,2018 12:37 PM UTC JavaScript - EJ 2 3
loading
Tags: DropDownList
Manolo Capdevila
Asked On November 13, 2018 10:50 AM UTC

Hi,

I need create a drop down and bind datasource with datamanager that call an action that return a json.

But I can't bind this drop down

I attach an example. The last drop down (dropdown2) call getGames2 that return a json, but it is not binded




Attachment: DropDownLocalData_e3e2412c.zip

Prince Oliver [Syncfusion]
Replied On November 14, 2018 12:04 PM UTC

Hi Manolo, 
 
Thanks for contacting Syncfusion support. 
 
We have checked the provided sample and were able to reproduce the reported issue in our end. Since JsonAdaptor cannot be used with Url, we suggest you to use UrlAdaptor  to fetch data from Controller method. Kindly refer to the following code snippet. 
 
[View] 
<script type="text/javascript"> 
  var listObj2 = new ej.dropdowns.DropDownList({ 
      placeholder: 'Select a game', 
      dataSource: new ej.data.DataManager( 
          { 
              url: "@Url.Action("getGames2", "Dropdownlist")", 
              adaptor: new ej.data.UrlAdaptor(), 
              crossDomain: true 
          }), 
      fields: { text: 'Game', value: 'Id' }, 
  });  
  listObj2.appendTo('#dropdown2'); 
</script> 
 
[Controller] 
public JsonResult getGames2() 
{ 
    var data = new DropdownlistGameList().DropdownlistGameLists(); 
    return Json(new { result = data }); 
} 
 
Regards, 
Prince 



Manolo Capdevila
Replied On November 14, 2018 02:58 PM UTC

Hi,

I've change the example to your configuration. Method getGames is called, but the dorp down not show the data


Attachment: DropDownLocalData_b621036c.zip

Christopher Issac Sunder K [Syncfusion]
Replied On November 15, 2018 12:37 PM UTC

Hi Manolo,  
 
Thanks for the update. 

We have validated the reported issue in our end. This issue occurs only on adding debugger to the controller method. As the component focus will be lost (blur) while making request, popup will not be opened on blur component. The sample will work fine when the debugger on controller is removed.  

If still you need to ensure this with debugger, you can set this.isActive and this.beforePopupopen as true as shown in the below code 

var listObj2 = new ej.dropdowns.DropDownList({ 
            placeholder: 'Select a game', 
            dataSource: new ej.data.DataManager( 
                { 
                    url: "@Url.Action("getGames2", "Dropdownlist")", 
                    adaptor: new ej.data.UrlAdaptor(), 
                    crossDomain: true 
                }), 
            fields: { text: 'Game', value: 'Id' }, 
            
            actionComplete: function (args) { 
                this.isActive = true; 
                this.beforePopupOpen = true; 
             
            } 
        }); listObj2.appendTo('#dropdown2'); 

Please let us know if you have any other concerns. 

Thanks, 
Christo

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.

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

;