|
<SfComboBox @ref="ComboObj" TValue="string" @bind-Value="ComboValue" TItem="TItem" DataSource="@DataSource" AllowFiltering="true">
<ComboBoxFieldSettings Text="Name" Value="Name"></ComboBoxFieldSettings>
<ComboBoxEvents TValue="string" Filtering="onFiltering"></ComboBoxEvents>
<ComboBoxTemplates TItem="TItem">
<NoRecordsTemplate>
<div>
<div id="nodata">You can add a new value by using the button below.</div>
<button id="btn" class="e-control e-btn" @onclick="@New">New</button>
</div>
</NoRecordsTemplate>
</ComboBoxTemplates>
</SfComboBox>
public void New()
{
List<TItem> newItem = new List<TItem>
{
new TItem() { Name = Text, Code = 5 },
};
this.ComboObj.AddItem(newItem);
this.ComboObj.HidePopup();
ComboValue = Text;
} |