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

Add Items to ListBox

Thread ID:





132669 Sep 14,2017 04:02 PM UTC Sep 19,2017 12:09 PM UTC JavaScript 5
Tags: ejListBox
Carsten Buchmann
Asked On September 14, 2017 04:02 PM UTC

I try to add some items to a listbox with value and text:

                    .ListBoxFields(f => f.Text("Name").Value("Value")
                    .ClientSideEvents(e => e.CheckChange("LocationsChanged"))

                listbox.ejListBox("addItem", {Value: location.Id, Name: location.Name + " " + location.PostCode + " " + location.City });

And I get this:

How can add a object to the listbox?

Kind regards,

Arun Palaniyandi [Syncfusion]
Replied On September 15, 2017 10:06 AM UTC

Hi Carsten, 

Sorry for the inconvenience caused. 

We were able to reproduce the reported issue with addItem, which has been already fixed in the Volume 3, 2017( version and above. Hence we suggest you to upgrade to our latest version to get this issue resolved. 

Arun P 

Carsten Buchmann
Replied On September 15, 2017 02:22 PM UTC

Hi Arun,

thanks. The update made my day.



Arun Palaniyandi [Syncfusion]
Replied On September 18, 2017 07:23 AM UTC

Hi Carsten,  
We are glad that our solution has resolved your issue.  
Please let us know if you have any queries in future.  
Arun P.  

Carsten Buchmann
Replied On September 18, 2017 01:38 PM UTC

Hi Arun,

unfortunately it doesn't work. Indeed I can add items, but they not stored as expected. I can't get the value back out of the selected items:


In the property text and value are the same values.

Kind regards,


Arun Palaniyandi [Syncfusion]
Replied On September 19, 2017 12:09 PM UTC

Hi Carsten,  
Thanks for your update.   
We have checked the reported scenario and we can reproduce your issue. As you have said, items can be added but cannot be stored and this is because you have not given the datasource property to the ListBox. Adding items to Listbox when the datasource is not given, will add the items by taking the given object’s text value through appending the text in the ListBox <ul>. Also, you cannot take the value field because the given text value is considered as the value field in this case. So, we suggest to bind an empty datasource to the ListBox and then you can add items to it. Please find the below code snippets.   
           dataSource:[],    // Bind an empty datasource   
            fields: {   
            text: "Name" ,value:"Value" }   
          $("#selectgroup").ejListBox("addItem", {   
            Name: location.Name, Value: location.Id  });   
Please try the given workaround, and if you still face any issue let us know, so that we would help you out better.   
Arun P.   


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