Skip to content

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

template
<c-select-string-value 
    :model="person" 
    for="jobTitle"
    method="getSuggestedJobTitles"
/>
template
<c-select-string-value 
    v-model="title"
    label="Job Title"
    for="Person"
    method="getSuggestedJobTitles"
/>
c#
class Person 
{
    public int PersonId { get; set; } 

    public string JobTitle { get; set; }

    [Coalesce]
    public static async Task<ICollection<string>> GetSuggestedJobTitles(AppDbContext db, string search) 
    {
        return await 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.

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 the model 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 provided model 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.

eager?: boolean = false

True if the bound value should be updated as the user types. Otherwise, the bound value is updated when focus is lost or when a suggested value is chosen. This is only applicable for Vuetify 2 - in Vuetify 3, this is the default behavior.


Coalesce is a free and open-source framework created by IntelliTect to fill our desire to create better apps, faster. IntelliTect is a high-end software architecture and development consulting firm based in Spokane, Washington.

If you're looking for help with your software project, whether it be a Coalesce application, other technologies, or even just an idea, reach out to us at info@intellitect.com — we'd love to start a conversation! Our clients range from Fortune 100 companies to local small businesses and non-profits.