Jquery Datatables pro phrase filter complete

0

I'm using Jquery's datatables, I always use it, but today I have a situation I did not find in its documentation. And the next, when the query is done it brings me the value of several fields comparing by words, I need the search to be done by the complete sentence in all the columns and not comparing word by word of all the columns.

    
asked by anonymous 15.09.2017 / 19:57

2 answers

1

search.smart enables smart filter activation and inactivation

Smart Filter :

Breaks user input into individual words and then matches those words in any position and in any order in the table (instead of simple to do a simple string comparison).

link

$('#example').dataTable( {
  "search": {
    "smart": false
  }
} );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">

<table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </tfoot>
        <tbody>
            <tr>
                <td>Paul Byrd</td>
                <td>Chief Financial Officer (CFO)</td>
                <td>New York</td>
                <td>64</td>
                <td>2010/06/09</td>
                <td>$725,000</td>
            </tr>
            <tr>
                <td>Yuri Berry</td>
                <td>Chief Marketing Officer (CMO)</td>
                <td>New York</td>
                <td>40</td>
                <td>2009/06/25</td>
                <td>$675,000</td>
            </tr>
            <tr>
                <td>Angelica Ramos</td>
                <td>Chief Executive Officer (CEO)</td>
                <td>London</td>
                <td>47</td>
                <td>2009/10/09</td>
                <td>$1,200,000</td>
            </tr>
       </tbody>
    </table>
    
15.09.2017 / 20:20
2

You can search by enclosing text in double quotation marks or disable the Smart Search function in DataTable by adding this setting when you start the table:

$('#tabela').dataTable({
  "search": {
    "smart": false
  }
});
    
15.09.2017 / 20:13