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

dynamic loading of list items

Thread ID:





128486 Jan 25,2017 01:46 PM UTC Jan 25,2017 04:17 PM UTC JavaScript 2
Tags: ejDropDownList
Michael Salzlechner
Asked On January 25, 2017 01:46 PM UTC

We have tried to create a dropdownlist that fills dynamically

tried to create a dropdownlist empty first and then use additem to add items

                targetID: "carsList",
                watermarkText: "Select a car",
                width: "100%"

var target = $('#selectCar').data("ejDropDownList");
var newitems = [
   { text: "India"},
   { text: "Pakistan"},
    target.addItem(newitems  );

this fails. looks like you cannot create a dropdownlist without items
tried it with adding an empty item first this works but I cant remove the empty items

I need to be able to change the items in the list dynamically



Michael Salzlechner
Replied On January 25, 2017 02:11 PM UTC

looks like I may have solved this but if there is a better way let me know

here is what I ended up with

1) create the dropdownlist with an item with blank text
2) use the dataSource option to change the data dynamically

    dataSource: [{text:""}],
                targetID: "carsList",
                watermarkText: "Select a car",
                width: "100%"


var newitems = [
   { text: "India"},
   { text: "Pakistan"},
  target.option("dataSource", newitems);

Karthikeyan Viswanathan [Syncfusion]
Replied On January 25, 2017 04:17 PM UTC

Hi Michael Salzlechner,       
Thanks for contacting Syncfusion support. 
No Need to assign empty value to DropDownList. It will be rendered also without any datasource. Please find the below code snippet: 
                fields: { id: "empid", text: "text", value: "text" } 
                                                var inst = $('#bikeList').ejDropDownList("instance"); 
                                                inst.option("dataSource", BikeList); 
JS Playground sample link: http://jsplayground.syncfusion.com/zg12b3yt  
Please let us know if you have any other queries.  
Karthikeyan V.   


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

or the page will be automatically redirected to 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