Manipulating Chips programmatically

Hi. I'm trying to understand what the correct method of manipulating chips through code is:

For example:

@using Syncfusion.EJ2.Blazor.Buttons;

    <EjsChipList @ref="ListReference" Selection="Selection.None" EnableDelete="true">
        <ChipCollection>
            <ChipListChip Text="First Chip"></ChipListChip>
        </ChipCollection>
    </EjsChipList>

@code
{
     EjsChipList ListReference { get; set;}

     // This works as expected
     private void AddChip()
     {
          ChipModel chip = new ChipModel();
          chip.Text = "Chip text";
          ListReference.Add(chip);
     }

     private void AlternateAddChip()
     {
          ChipListChip chip = new ChipListChip();

          chip.Text = "Chip text";

          List<ChipListChip> chipLists = (List<ChipListChip>)ListReference.Chips;
          chipLists.Add(newchip);
     }
}


AddChip() is based off an example I saw provided to another user on these forums and the chips show up correctly on the page. However the ListReference does not appear to have a reference to the added chips. It's Chips count remains exactly what it was originally initialized with. No additionally added chips can be referenced for further manipulation.

AlternateAddChip() is the result of my own experimentation. It appears to correctly add the chips, and ListReference correctly maintains the reference to these newly added chips. However - when creating and assigning data to ChipListChip new, Visual Studio gives warnings saying "Component parameter 'Text' should not be set outside of its component".

What is the correct method of manipulating chips? The second method is violating guidelines from the Blazor devs but since it is an un-rendered component, it doesn't appear to cause any issues.

10 Replies

OS Osama March 2, 2020 03:57 AM UTC

Also - how are we supposed to add avatar icons to chips? The examples are shown using CSS styles but that's not a realistic approach for a dynamic application. I can't manually have CSS styles created for every possible user. I need to be able to set the image url on the component.


SP Sowmiya Padmanaban Syncfusion Team March 2, 2020 10:10 AM UTC

Hi Osama,  
 
Greetings from Syncfusion support. 
 
Query1 -  Dynamically add chip item. 
 
We have checked your attached code snippet. We suggest you to use the add() method of chip component. It is the proper way to adding chip to the Chip component. Refer the below code snippet. 
 
    public void onToggleClick() 
    { 
        var value = this.textbox.Value; 
        // You can get the update value in chip. 
        ChipModel chips = new ChipModel(); 
        chips.Text = value; 
        chip.Add(chips);         
    } 
 
However, we are able to replicate the reference not maintain issue and we are currently validating this issue from our end. We will update the validation details by tomorrow. 
 
Query 2 – ImageURL for chip component. 
 
Currently, we have not provided this functionality support in Chips. We are checking the feasibility of achieving your requirement. We will update the validation details on next Monday (9/3/2020). 
 
We appreciate your patience until, then. 
 
 
Regards,  
Sowmiya.P 



SP Sowmiya Padmanaban Syncfusion Team March 3, 2020 01:32 PM UTC

Hi Osama, 
 
Query1 – chip reference is not maintained. 
 
We have validated your reported issue. We have consider this as a bug from our end. Currently we have working on release related works. So, we will include the fix for this bug in our March last Weekly Release which is expected to be released at the end of March. 
 
Refer the below link to know the bug status. 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 



SP Sowmiya Padmanaban Syncfusion Team March 17, 2020 09:55 AM UTC

Hi Osama,  
 
We have validated your requirement ( ImageURL property for chip component). We have consider this as a feature from our end. It will be included in our Volume 1 SP1 Release which is expected to be released at the end of April. Please be patience, until then. 
 
Track the below link for bug status. 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 



SP Sowmiya Padmanaban Syncfusion Team March 25, 2020 11:11 AM UTC

Hi Osama,  
 
Thanks for your patience. 
 
We are happy to announce that Volume 1 Beta Release is rolled out successfully. In this release, we have included a fix “Chips property is not updated properly”. To access this fix, we suggest you to update the package to the latest version(V18.1.0.36-beta). 
 
In this release, we have included some common changes in all EJ2 components. Refer the below link to know the common changes. 
 
 
 
Refer the sample link for your reference. 
 
Please let us know, if you have any concerns. 
 
Regards,  
Sowmiya.P 



SP Sowmiya Padmanaban Syncfusion Team May 14, 2020 08:14 AM UTC

Hi  Osama,  
 
Sorry for the inconvenience. 
 
Due to some technical difficulties, we were unable to roll out this feature support in Volume 1 SP1 release. However, we have implemented this feature in Chip component and moved this feature from development phase to testing phase.  
  
We will roll out this feature support after completing the functionality testing  to ensure the stability of the feature with all functionalities of the component. So, we will include this feature support in our next weekly release. 
 
We appreciate your patience . 
 
 
Regards,  
Sowmiya.P 



SP Sowmiya Padmanaban Syncfusion Team June 2, 2020 11:06 AM UTC

Hi Osama,  
 
We are glad to announce that our patch release (v18.1.54) is rolled out successfully. In this release,  we have included a fix for “ImageURL support in Chip component”. To access this fix, we suggest you to update the (Syncfusion.Blazor) to the latest version(v18.1.54). 
 
Refer the below code snippet. 
 
<SfChipList> 
    <ChipCollection> 
        <ChipListChip Text="CEO" LeadingIconUrl="http://ej2.syncfusion.com/demos/src/chips/images/anne.png"></ChipListChip> 
        <ChipListChip Text="CEO" LeadingIconUrl="http://ej2.syncfusion.com/demos/src/chips/images/anne.png"></ChipListChip> 
    </ChipCollection> 
</SfChipList> 
 
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, 
Sowmiya.P 



RM Robert Mrobo replied to Sowmiya Padmanaban January 12, 2022 08:42 AM UTC

What is the correct way of doing this in 2022 because when I try to set a property like Text, on a ChipItem, the IDE tells me that the Component parameter "Text" should not be set outside of component.

After trying to assign ci.Text, that's where I call _selectedTeamChip.AddChip(ci);

syncfusion.jpg



SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team January 13, 2022 02:46 PM UTC

Hi Roberto, 
 
We validated your reported problem with Chip component. The reported warning will not affect the rendering of the Chip in UI.  
 
However, we will validate further to provide you details regarding the our validation for resolving the warning in two business days on 18th January 2022. 
 
We appreciate your patience. 
 
Regards, 
Shameer Ali Baig S. 



KR Keerthana Rajendran Syncfusion Team January 18, 2022 03:39 PM UTC

Hi Roberto, 
 
We have considered the scenario “Provide items support for Chip component” as a feature , but we do not have any immediate plan to implement this feature. At the planning stage for every release cycle, we review all open features.  
 
Usually, Syncfusion will plan and implement the features based on feature rank, customer requested count and volume wish-list. We will let you know when this feature is implemented. 
 
The status of feature implementation can be tracked through the below portal link. 
 
 
Once this feature is implemented, you can directly add items to the Chip component without using the AddChip method and the warning will not occur. 
 
You can use the current way (AddChip method) to add items until then and the warning will not affect the Chip rendering as mentioned earlier. 
 
Regards, 
Keerthana R. 


Loader.
Up arrow icon