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

Rerender ComboBox data (set dataSource to empty)

Thread ID:

Created:

Updated:

Platform:

Replies:

150788 Jan 20,2020 08:52 AM UTC Jan 24,2020 06:36 AM UTC Angular - EJ 2 4
loading
Tags: ComboBox
Unknown
Asked On January 20, 2020 08:52 AM UTC

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

Sevvandhi Nagulan [Syncfusion]
Replied On January 21, 2020 06:44 PM UTC

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 


Unknown
Replied On January 23, 2020 04:52 AM UTC

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):


Unknown
Replied On January 23, 2020 05:09 AM UTC

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

Sureshkumar P [Syncfusion]
Replied On January 24, 2020 06:36 AM UTC

Hi AC, 
 
 
Regards, 
Sureshkumar P 


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