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. Image for the cookie policy date
close icon

bind Syncfusion dropdownlist via json result on ajax call

Hi Guys,


  I would like to dynamically bind the data to the ejdropdownlist using the jquery  below ,
 
function populateLocation(areaId) {
 
       var locationdropDownlist = $('#JobLocationId').data("ejDropDownList");
 
       if (areaId != '') {
           jQuery.post("@Url.Action("GetSelectList", "SelectList")",
                  {  entityType : 'JobLocation',
                     field : 'AreaRefId',
                     value : areaId
                  },
              function (data) {
 
				
			//bind the data here .... ??               
                  
                                },
 
              "json");
       }

}

I have gone through the Essential JavaScript API Reference - v.13.1.0.30 but I don't find any javascript method that will allows me to do so ... please help by providing sample of how to achieve it.

Thanks

Regards

SK





11 Replies

KC Kasithangam C Syncfusion Team June 8, 2015 12:16 PM UTC

Hi SK Yong,

Thanks for using Syncfusion Products.

We have achieved your requirement “Dynamically bind the data to ejDropDownlist on ajax call” and please find the sample under the following location,

Sample: DropDown Sample

In this above sample, we have bind the data to the dropdown list on ajax call by using the property “dataSource” and please find the code for the same,

<code>

<script>

    function onClick() {


        $.ajax({

            url: '/DropDown/Add',

            type: 'POST'

        }).success(function (result) {

           

            BikeList = [

             { empid: "bk1", text: "Apache RTR" }, { empid: "bk2", text: "CBR 150-R" }, { empid: "bk3", text: "CBZ Xtreme" },

             { empid: "bk4", text: "Discover" }, { empid: "bk5", text: "Dazzler" }, { empid: "bk6", text: "Flame" },

             { empid: "bk7", text: "Fazzer" }, { empid: "bk8", text: "FZ-S" }, { empid: "bk9", text: "Pulsar" },

             { empid: "bk10", text: "Shine" }, { empid: "bk11", text: "R15" }, { empid: "bk12", text: "Unicorn" }

            ];


            var data1 = $("#bikeList").data("ejDropDownList");

            data1.option("dataSource", BikeList);


        })

    }

</script>

</code>


Please let us know if you have any further assistance,

Regards,

Kasithangam



SY SK Yong June 10, 2015 08:22 AM UTC

Hi Kasithangam,


  It works. Thanks for the assistance.

Regards

SK


KC Kasithangam C Syncfusion Team June 11, 2015 11:55 AM UTC

Hi SK Yong,
Thanks for your update.

Please get back to us if you have further queries.

Regards,
Kasithangam



SA sahana March 7, 2017 10:18 AM UTC

Hi,
 I am new to this Sync fusion,
I have to bind dropdown already saved value as selected and other values too..
Please guide me.
I tried above example,Its working when i will hard code values but when i am getting values in ajax call its not.

Thanks,
sahana


PO Prince Oliver Syncfusion Team March 8, 2017 09:23 AM UTC

Hi Sahana,     
    
Thank you for contacting Syncfusion support.     
    
We were unable to understand your query. If you are looking for binding remote data, please refer to the following UG Documentation link:    
  
Refer to the following link for online demo link for dropdownlist remote data sample:http://js.syncfusion.com/demos/web/#!/bootstrap/dropdownlist/databinding-remotedata 

If this is not your requirement, please provide detailed information on your requirement along with sample or code example with replication steps and screenshots of the requirement. It will help us provide solution.   
    
Regards,     
Prince   



ME Megatron March 8, 2017 07:43 PM UTC

Hi is there a way to do the same binding,

Scenario 1:
using a reference or Foreign Key table.

For e.g. if Customers had a FK key to Orders table,

  1. would it be possible to select the orders as the drop down
  2. would it possible to select the orders that are not already selected on the current page

Scenarios 2: using references as a Enum DropDown

Thanks



PO Prince Oliver Syncfusion Team March 10, 2017 11:53 AM UTC

Hi Megatron,   
  
Thank you for contacting Syncfusion support.   
  
We have prepared a sample as per your requirement in scenario 1, to bind foreign key value to dropdownlist. Kindly refer to the following link to the sample: 
  
We were unable to understand you query regarding enum dropdown in scenario 2. Can please provide screenshots, code example or sample explaining your requirement?   
  
Regards,   
Prince   



ME Megatron March 10, 2017 05:45 PM UTC

Hi thanks for the help, mine is inside a table like this

for e.g. inside a [Orders table] (FK to Country), user is selecting Country  and then State (FK to Country)





Since every Table row is different and my DropDownId are different in each row, I dont know how to find/filter based on the selected country in the DLL and and then filter the state, can you help me

I have to filter the states based on country selected, and I want to make it easy for me to reuse and efficient.
I have 2 other tables that I do this, so understanding this will help me reuse it.


thanks


SA sahana March 11, 2017 11:57 AM UTC

Hi,

I have scenario where need bind drop down with value which it is already in database and other values so that user can change.
e.g: states should be binded to drop down which user can modify and save it.

Thanks,


PO Prince Oliver Syncfusion Team March 13, 2017 12:54 PM UTC

Hi Megatron,    

Thanks for your update. 

You can filter the data from datsource using the datamanager filtering techniques. Kindly refer to the following link for more information on filtering: https://help.syncfusion.com/js/datamanager/filtering 

You can also find the required data from datasource using datamanager search queries. Kindly refer to the following link for more information on searching: https://help.syncfusion.com/js/datamanager/searching 

If this is not your requirement, kindly provide us a sample with screenshots and detailed explanation of your requirement. It will help us understand your query better and provide solution. 

Regards, 
Prince 



PO Prince Oliver Syncfusion Team March 13, 2017 04:44 PM UTC

Hi Sahana, 

Thanks for your update. 

We have prepared a sample as per your requirement to bind dropdownlist with value from database. Kindly refer to the following link for the sample: http://www.syncfusion.com/downloads/support/forum/119332/ze/DdlSqlSample-1165653243 

Regards, 
Prince 


Loader.
Live Chat Icon For mobile
Up arrow icon