2013-10-01 16 views
6

Używam fnFilter w datatables i podczas próby filtrowania "inv" wszystko inne zaczynając od "inv" również zostanie przefiltrowane. to jest "invc", "invk" są również wyświetlane w wyniku filtrowanym. Jak rozwiązać ten problem i uzyskać tylko dokładne wyniki?Jak uzyskać dokładne dopasowanie za pomocą fnFilter?

Kod:

$("#user-lock-status-filter select").change(function() { 
     oUserTable.fnFilter($(this).val(), 12); 
    }); 
+0

Co 'fnFilter' zrobić? – Johan

+0

służy do filtrowania danych w kolumnie. – puppuli

Odpowiedz

8

Zmiana ta

oUserTable.fnFilter($(this).val(), 12); 

do

oUserTable.fnFilter("^"+$(this).val()+"$", 12, false, false); 
//disabling smart search/regex and apply your own search 

Example

Doc

Params dla fnFilter

1.{string}: String to filter the table on 
2.{int|null}: Column to limit filtering to 
3.{bool} [default=false]: Treat as regular expression or not 
4.{bool} [default=true]: Perform smart filtering or not 
5.{bool} [default=true]: Show the input global filter in it's input box(es) 
6.{bool} [default=true]: Do case-insensitive matching (true) or not (false) 
+0

To nie działa, wciąż otrzymuję wiersze "invc" w wyszukiwaniu "inv". – puppuli

+0

poprawiono ... sprawdź – bhb

+0

Co oznaczają 4 i 5? – pete

Powiązane problemy