<p>AutoComplete NoRecordsTemplate Á custom button</p>
<SfAutoComplete @ref="AutocompleteObj" TValue="string" TItem="Country" @bind-Value="@AutoVal" Placeholder="Select" DataSource="@Countries" Width="250px">
<AutoCompleteTemplates TItem="Country">
<NoRecordsTemplate>
<span class='norecord'> NO DATA AVAILABLE</span>
<SfButton OnClick="@customFunction">Clear value and popup</SfButton>
</NoRecordsTemplate>
</AutoCompleteTemplates>
<AutoCompleteFieldSettings Value="Name"></AutoCompleteFieldSettings>
</SfAutoComplete>
@code {
SfAutoComplete<string, Country> AutocompleteObj;
public string AutoVal;
public class Country
{
public string Name { get; set; }
public string Code { get; set; }
}
List<Country>
Countries = new List<Country>
{
new Country() { Name = "Australia", Code = "AU" },
new Country() { Name = "Bermuda", Code = "BM" },
new Country() { Name = "Canada", Code = "CA" },
new Country() { Name = "Cameroon", Code = "CM" },
};
public async Task customFunction()
{
AutoVal = "";
await AutocompleteObj.HidePopupAsync();
}
}
|