Skip to content

docs(ChipList): Enhance Events example #2963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions components/chiplist/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ The `SelectedItemsChanged` fires when the user selects a chip from the ChipList.
SelectionMode="@ChipListSelectionMode.Multiple"
SelectedItems="@ChipListSelectedItems"
SelectedItemsChanged="@( (IEnumerable<ChipModel> selectedItems) => OnChipListSelectedItemsChanged(selectedItems) )"
OnRemove="@OnChipRemove"
TextField="@nameof(ChipModel.ChipText)"
IconField="@nameof(ChipModel.ChipIcon)"
RemovableField="@nameof(ChipModel.isChipRemovable)">
OnRemove="@OnChipRemove">
</TelerikChipList>

@code {
Expand All @@ -48,32 +45,34 @@ The `SelectedItemsChanged` fires when the user selects a chip from the ChipList.

private void OnChipRemove(ChipListRemoveEventArgs args)
{
ChipModel removedChip = args.Item as ChipModel;
ChipModel removedChip = (ChipModel)args.Item;

args.IsCancelled = false; //set this to true to cancel the removal of the chip
args.IsCancelled = false; // false by default. Set to true to cancel chip removal.

ChipListSource.Remove(removedChip);
}

private List<ChipModel> ChipListSource { get; set; } = new List<ChipModel>()
{
new ChipModel()
{
ChipText = "Audio",
ChipIcon = SvgIcon.FileAudio,
isChipRemovable = true
Text = "Audio",
Icon = SvgIcon.FileAudio,
Removable = true
},
new ChipModel()
{
ChipText = "Video",
ChipIcon = SvgIcon.FileVideo,
isChipRemovable = true
Text = "Video",
Icon = SvgIcon.FileVideo,
Removable = true
}
};

public class ChipModel
{
public string ChipText { get; set; }
public ISvgIcon ChipIcon { get; set; }
public bool isChipRemovable { get; set; }
public string Text { get; set; } = string.Empty;
public ISvgIcon? Icon { get; set; }
public bool Removable { get; set; }
}
}
````
Expand Down
Loading