Shahin
Shahin

Reputation: 12851

jQuery Datatable search option ( alphabetical )

I use jQuery Datatables Plugin.
When I type a in search box Datatables filters all data in table contains a letter
But I want to search (alphabetical ) like this
when I type 'a' just filters all data starts with 'a'

Upvotes: 1

Views: 4127

Answers (2)

red-X
red-X

Reputation: 5138

give this a try then:

oTable.fnFilter( '^a.*', yourColumn, true );

'^a.*' the regex searching for, replace the a with your filter

yourColumn speaks for itself

true needed to treat the first string as a regex, check the api

Upvotes: 1

king14nyr
king14nyr

Reputation: 715

You need to modify the DataTables initialization and customize how the filtering works. Check the link below, same exact situation. You'll need to grab the data from the filter box and filter on a stricter RegEx focusing on the beginning of the data in the cells.

http://www.datatables.net/forums/discussion/255/customising-the-way-the-filter-works/p1

Upvotes: 2

Related Questions