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

How to a clear an ejs-listbox

Thread ID:

Created:

Updated:

Platform:

Replies:

146343 Jul 31,2019 10:21 PM UTC Aug 2,2019 07:40 AM UTC ASP.NET Core - EJ 2 3
loading
Tags: ListBox
Michael Lambert
Asked On July 31, 2019 10:21 PM UTC

I have no issues with assigning a datasource to a listbox:
ie.

…..
            .done(function (result) {
                var lstSignedUp = document.getElementById('lstSignedUp').ej2_instances[0];
                lstSignedUp.dataSource = result;
                lstSignedUp.dataBind
            })

But how do I un-assign the datasource so the listbox displays no items?
I tried this, but nothing happens,

        let lstSignedUp = document.getElementById('lstSignedUp').ej2_instances[0];
        lstSignedUp.dataSource = null;
        lstSignedUp.dataBind

I've also tried:
        lstSignedUp.listData = null    //again the list box does not empty.

Thanks,
Mike


Vinoth Kumar Sundara Moorthy [Syncfusion]
Replied On August 1, 2019 11:07 AM UTC

Hi Mike, 
 
Good day to you. 
 
We have checked your provided code snippet and we suggest you use refresh method instead of dataBind to clear the ListBox as like in the below code example, 
 
Code Example 
function onCreate() { 
    var obj = document.getElementById('listbox').ej2_instances[0]; 
    obj.dataSource = null; 
    obj.refresh(); 
} 
 
For your convenience, we have prepared a sample and the same can be downloaded from below link, 
 
Could you please check the above sample and get back to us if you need any further assistance on this? 
 
Regards, 
Vinoth Kumar S 


Michael Lambert
Replied On August 1, 2019 12:51 PM UTC

Worked
Thanks!

Vinoth Kumar Sundara Moorthy [Syncfusion]
Replied On August 2, 2019 07:40 AM UTC

Hi Mike, 
  
You are most welcome. Please feel free to contact us if you need any further assistance on Syncfusion components. 
  
Regards, 
Vinoth Kumar S 


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.

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