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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Change the datasource programmatically

Thread ID:





142324 Jan 28,2019 05:02 PM UTC Jan 29,2019 07:36 AM UTC jQuery 1
Tags: ejDropDownList
Marco Giorgi
Asked On January 28, 2019 05:02 PM UTC

I have a dropdownlist that I create with the following code:

$('td#' + selectedCol + ' .units').ejDropDownList({
                                                width: 250,
                                                popupHeight: 300,
                                                watermarkText: "Select a unit",
                                                dataSource: unitsOfMeasure,
                                                fields: {
                                                    text: "text",
                                                    value: "value"

now, when the user click a button, I'd like to change the dataSource and load another set of items, contained in the variable unitOfMeasure2, 
How can I do it in the fastest and most performant way?


Prince Oliver [Syncfusion]
Replied On January 29, 2019 07:36 AM UTC

Hi Marco, 

Thank you for contacting Syncfusion support. 

We can use the dataSource property from the control’s instance and assign new data to the control in the button click handler. Kindly refer to the following code snippet. 

    var ddlObj, unitsOfMeasure, unitOfMeasure2; 
    ddlObj = $('td#' + selectedCol + ' .units').ejDropDownList({ 
        width: 250, 
        popupHeight: 300, 
        watermarkText: "Select a unit", 
        dataSource: unitsOfMeasure, 
        fields: { 
            text: "text", 
            value: "value" 
    function btnClick() { 
        ddlObj.setModel({ dataSource: unitOfMeasure2}); 

We have attached a sample for your reference, please find the sample at the following location: https://jsplayground.syncfusion.com/q2cpcg5q 

Please let us know if you need any further assistance on this. 



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