How to find selected chips by index

Hi Team,

In my use case, I've the same text for multiple chips as well. so I need to highlight chips which is recently clicked based on the index. On the chip, click event, I can capture the index of chip but how to set the selectedchip based on index value. It seems that selectedchip attribute only accepts string[].

Please suggest to how set selected chip by index value.



Many thanks
Seetha.

3 Replies 1 reply marked as answer

SP Sowmiya Padmanaban Syncfusion Team March 2, 2021 11:08 AM UTC

Hi Seetha,  
 
Greetings from Syncfusion support. 
 
We have checked your requirement with chip component. we suggest you to use the value property for selecting the chips in chip component. 
 
Please, refer the below code snippet. 
 
@using Syncfusion.Blazor.Buttons 
 
<SfChip SelectedChips="@selection" Selection="SelectionType.Multiple"> 
    <ChipItems> 
        <ChipItem Text="Anne" Value="0"></ChipItem> 
        <ChipItem Text="Anne" Value="1"></ChipItem> 
        <ChipItem Text="Laura" Value="2"></ChipItem> 
        <ChipItem Text="Margaret" Value="3"></ChipItem> 
    </ChipItems> 
</SfChip> 
@code { 
    public string[] selection = new string[] { "0", "2" }; 
} 
 
Please, refer the below sample link. 
 
 
Please let us know, if you have any concerns. 
 
Regards, 
Sowmiya.P 


Marked as answer

SE Seetha March 3, 2021 02:20 AM UTC

Thank you Sowmiya. It works well.


SP Sowmiya Padmanaban Syncfusion Team March 3, 2021 04:47 AM UTC

Hi Seetha,  
  
We are happy to hear that our provided solution meets your requirement. Please contact us, if you need any help from us. 
  
Regards,  
Sowmiya.P 


Loader.
Up arrow icon