Search
Add a search box to the index page
You can enable search-as-you-type for any resource by calling EnableSearch() on the index page builder. This adds a text search box above the grid on the index page and filters the rows in the grid based on the value the user types.
For an EF Core resource, you can pass a filter expression which will be passed to the database. The example below searches bookings by their reference and by the traveller's last name:
resource.Index(index =>
{
index.EnableSearch(term => booking =>
booking.Reference.Contains(term) || booking.Traveller.LastName.Contains(term));
});Make sure the underlying database columns you filter on have the appropriate indexes, so that the search does not do a full table scan and bring your database to a halt.
The grid searches as someone types, with a short debounce.


The filter runs on the database, so EF Core must be able to translate the expression to SQL. You can also use database functions in the expression.
Changing the placeholder
The search box's default placeholder is "Search" plus the plural resource label, for example "Search Bookings...". Change it by setting the Placeholder in the search builder.
index.EnableSearch(
term => booking => booking.Reference.Contains(term),
search => search.Placeholder = "Search by reference");To change the default placeholder for every resource, see global labels.
Searching a custom data source
When using a custom data source, call EnableSearch() without a filter expression. StellarAdmin passes the search text when calling the ListAsync() method, and your data source decides which records match.