c-select-string-value¶
A dropdown component that will present a list of suggested string values from a custom API endpoint. Allows users to input values that aren't provided by the endpoint.
Effectively, this is a server-driven autocomplete list.
Examples¶
<c-select-string-value
:model="person"
for="jobTitle"
method="getSuggestedJobTitles"
/>
class Person
{
public int PersonId { get; set; }
public string JobTitle { get; set; }
[Coalesce]
public static Task<ICollection<string>> GetSuggestedJobTitles(AppDbContext db, string search)
{
return db.People
.Select(p => p.JobTitle)
.Distinct()
.Where(t => t.StartsWith(search))
.OrderBy(t => t)
.Take(100)
.ToListAsync()
}
}
Props¶
for: string | Property | Value
A metadata specifier for the value being bound. One of:
- A string with the name of the value belonging to
model
. - A direct reference to a metadata object.
- A string in dot-notation that starts with a type name.
- A string with the name of the value belonging to
model: Model
- An object owning the value that was specified by the
for
prop. If provided, the input will be bound to the corresponding property on themodel
object. method: string
- The camel-cased name of the Custom Method to invoke to get the list of valid values. Will be passed a single string parameter
search
. Must be a static method on the type of the providedmodel
object that returns a collection of strings. params?: DataSourceParameters
- An optional set of Data Source Standard Parameters to pass to API calls made to the server.
listWhenEmpty?: boolean = false
- True if the method should be invoked and the list displayed when the entered search term is blank.