|
<SfMultiSelect TValue="int[]" ModelType="models" Placeholder="..." DataSource="@Contacts" Mode="@VisualMode.Box">
<MultiSelectTemplates>
<ItemTemplate>
<span>@((context as Contact).Name)</span>
</ItemTemplate>
<ValueTemplate>
<SfTooltip Content="@((context as Contact).Email)">
<Syncfusion.Blazor.Buttons.SfButton ID="btn" @ref="buttonObj" Created="onCreated" @ondblclick="ClickOnChip">
<span>@((context as Contact).Name)</span>
</Syncfusion.Blazor.Buttons.SfButton>
</SfTooltip>
</ValueTemplate>
</MultiSelectTemplates>
<MultiSelectFieldSettings Text="Name" Value="Id"></MultiSelectFieldSettings>
</SfMultiSelect>
@code
{
Syncfusion.Blazor.Buttons.SfButton buttonObj;
public string selectedItem { get; set; } = string.Empty;
public List<Contact> Contacts = new List<Contact>()
{
};
Type models = typeof(Contact);
public class Contact
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
}
public async Task onCreated()
{
JSRuntime.InvokeVoidAsync("OnCreated", buttonObj.ID);
}
protected async Task ClickOnChip(MouseEventArgs e)
{
selectedItem = await JSRuntime.InvokeAsync<string>("OnItem", buttonObj.ID);
// I need to catch the doubleclick event and get the Id of the Contact bound to the chip
}
}
|
|
var selectedValue = null;
window.OnCreated = (id) => {
document.getElementById(id).ondblclick = function (e) {
selectedValue = e.target.innerText;
}
};
window.OnItem = (id) => {
return selectedValue;
};
|