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

Rerender ComboBox data (set dataSource to empty)

Hello,

I am trying to set comboBox dataSource to empty array but I am still can see data that was rendered before my changes.

What am I doing:
On load I want to see one data in my comboBox. After value change in different comboBox I want to rerender data. Some times in cat be rerender to empty comboBox. I am doing in like this:
myFile.html
<ejs-combobox #ComboBox {someProperties}></ejs-combobox>
myFile.ts
@ViewChild('ComboBox') MyComboBox: ComboBox;
{someCode}
public setDataSource() {
     if (this.data.length < 0)
          this.MyComboBox.dataSource = [];
     else
          this.MyComboBox.dataSource = this.data;
}

If I set my dataSource to empty array - I see previuosly set values. If I set dataSource to some data - I see correct data. Maybe I am doing something wrong and must delete dataSource in some different way?

This is what data I am getting after setting dataSource to empty:



P.S. I am getting my data from WebAPI. I am using ej2-angular-dropdows version 17.1.49

4 Replies

SN Sevvandhi Nagulan Syncfusion Team January 21, 2020 01:44 PM

Hi AC, 

Greeting from Syncfusion support. 

We can able to reproduce the reported issue in our end. The cause of the issue is ulElement not updated property. You can set the value null to ulElement and list as mentioned in the below code snippet, 

    OnClick1(args) 
    { 
        this.localObj.dataSource = []; 
        this.localObj.dataBind(); 
        (this.localObj as any).ulElement = null; 
        (this.localObj as any).list = null; 
    } 

Please find the sample below, 


Regards, 
Sevvandhi N 



UN Unknown Syncfusion Team January 22, 2020 11:52 PM

Hello,

thank you for your answer. It works almost perfect but in some cases if I set my dataSource ant other stuff like in your example after using combobox destroy event I am getting an error (it looks like it is trying to hide popup event if it was not opened):



UN Unknown Syncfusion Team January 23, 2020 12:09 AM

I fixed this issue by also setting listData property to null:
(this.localObj as any).listData = null;


SP Sureshkumar P Syncfusion Team January 24, 2020 01:36 AM

Hi AC, 
 
 
Regards, 
Sureshkumar P 


Loader.
Live Chat Icon For mobile
Up arrow icon