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

How to a clear an ejs-listbox

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

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

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;

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


3 Replies

VK Vinoth Kumar Sundara Moorthy Syncfusion Team 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; 
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? 
Vinoth Kumar S 

ML Michael Lambert August 1, 2019 12:51 PM UTC


VK Vinoth Kumar Sundara Moorthy Syncfusion Team 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. 
Vinoth Kumar S 

Live Chat Icon For mobile
Up arrow icon