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

Cannot dynamically add chips

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. 

4 Replies

SP Sowmiya Padmanaban Syncfusion Team 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 



SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team 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. 



MA Mayur 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


SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team 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. 


Loader.
Live Chat Icon For mobile
Up arrow icon