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

Cannot dynamically add chips

Thread ID:

Created:

Updated:

Platform:

Replies:

150972 Jan 26,2020 08:16 PM UTC Feb 3,2020 07:25 AM UTC Blazor 4
loading
Tags: Chips
Mayur
Asked On January 26, 2020 08:16 PM UTC

I am trying to emulate the input chip control of Angular. 

The initial list of chips is empty. The user types in some text and presses enter. The text gets added to the chiplist. However, there is no way to do it. The documentation around how to do it does not exist. Any direct manipulation (via Add() method of EjsChipList) is error-prone as the component cannot be rendered unless there is at least one element.

Kindly advice. 

Sowmiya Padmanaban [Syncfusion]
Replied On January 27, 2020 12:37 PM UTC

Hi Mayur,  
 
Greetings from Syncfusion support. 
 
We have checked your reported query about the dynamically add items. We have prepared a simple sample for your requirement. In that sample, we have added the entered text in chip component.  
 
Refer the sample link below. 
 
Now, we have faced some issue while adding more than two items dynamically. We might consider this as a bug from our end. This bug fix will be included in our Volume 4 SP1 Release which is expected to be released at the end of January. Please be patience, until then. 
 
Please let us know, if you need any further assistance on this. 
 
 
Regards,  
Sowmiya.P 


Shameer Ali Baig Sulaiman Ali Baig [Syncfusion]
Replied On January 31, 2020 07:21 AM UTC

Hi Mayur, 
  
We are glad to announce that our Essential Studio 2019 Volume 4 Service Pack release v17.4.0.46 is rolled out and is available for download under the following link. 
 
  
In this release, we have included a fix for “Dynamically add more than one chip items to Chip component”. 
  
For your reference, we have prepared a simple sample. Refer the sample link below. 
 
  
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Shameer Ali Baig S. 


Mayur
Replied On January 31, 2020 08:15 PM UTC

Hello,

Thank you for your response. However, the sample works only if there is at least one chip present in the collection. What is the correct way to dynamically initialize the component with no chip and adding more dynamically based on the user input?

Thanks,
Mayur

Shameer Ali Baig Sulaiman Ali Baig [Syncfusion]
Replied On February 3, 2020 07:25 AM UTC

Hi Mayur, 
 
Thanks for the update. 
 
For your information, if no chip collection is not added on initial rendering, then Chip component will render with a single chip item. It is the default behavior of the component. Thus, we cannot render empty Chip on initial rendering, to add the Chip list dynamically. 
 
Though, to achieve your expected requirement, you can initialize the Chip control without adding any text and add styles for empty chip (display as none) to hide the initially rendered empty Chip. Then, you can dynamically add the Chip items on user input. 
 
 
Refer the below code block. 
 
 
<EjsChipList @ref="chip" EnableDelete="true" CssClass="custom"> 
    <ChipCollection> 
        <ChipListChip></ChipListChip> 
    </ChipCollection> 
</EjsChipList> 
 
@code{ 
    EjsButton ToggleBtn; 
    EjsTextBox textbox; 
    EjsChipList chip; 
 
    public void onToggleClick() 
    { 
        var value = this.textbox.Value; 
        ChipModel chips = new ChipModel(); 
        chips.Text = value; 
        chip.Add(chips); 
    } 
 
} 
 
<style> 
    .e-chip-list .custom.e-chip:first-child { 
        display: none; 
    } 
</style> 
 
 
We have also prepared sample for your convenience.  
 
 
Please let us know, if you need any assistance. 
 
Regards, 
Shameer Ali Baig 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