Skip to content

Feature Request: Native support for minimum search length #3241

@arce701

Description

@arce701

Currently, yajra/laravel-datatables doesn't provide native support for setting a minimum search length before triggering server-side queries. This leads to unnecessary database queries with 1-2 character searches, poor performance with large datasets, and suboptimal UX for autocomplete-style searches.

Current workarounds include backend approaches like if (strlen($searchValue) > 0 && strlen($searchValue) < 3) { return $builder->where('id', -1); } which still execute database queries, or frontend approaches using parameters with initComplete JavaScript which require manual injection.

I propose adding a minSearchLength() method to the HTML builder that would work like $this->builder()->minSearchLength(3)->serverSide() to prevent server requests until minimum length is reached, clear results when backspacing below minimum, and work seamlessly with existing DataTables configuration.

This would provide improved performance for large datasets, better UX for name/text searches, consistent behavior across implementations, and eliminate the need for custom JavaScript workarounds. This feature would be particularly valuable for customer/user search tables where 3+ character searches provide meaningful results while reducing server load.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions