pcezar91
pcezar91

Reputation: 111

Datatable filtering href value - Bypassing anchor filters

One of the columns in my table.datatable is the name of the enterprise that are registered on my db. I wrapped the name of each enterprise with an 'a' tag for a quick option to edit the enterprise profile, but the issue is that the filters are also filtering the url.

Example: I want to filter for "DPVNice" the client and owner of the system. But the first enterprise, which is "Advertising", and its url is "http://localhost/dpvnice/admin/empresa/4/editar". I tried changing the name of the folder in localhost and it solves this problem, but i can't change the name on production that has DPVNice on it.

Bottomline, is there a way to bypass filtering anything with the 'a' tag?

Upvotes: 1

Views: 1062

Answers (1)

Gyrocode.com
Gyrocode.com

Reputation: 58900

You can use data-search attribute on <td> element to specify value used for filtering. Below is an excerpt from the manual:

DataTables will automatically detect the following attributes on HTML cells:

data-sort or data-order - for ordering data

data-filter or data-search - for search data

Example:

<tr>    
    <td data-search="Tiger Nixon">T. Nixon</td>    
    <td>System Architect</td>    
    <td>Edinburgh</td>    
    <td>61</td>    
    <td data-order="1303682400">Mon 25th Apr 11</td>    
    <td data-order="3120">$3,120/m</td>
</tr>

See manual or example for more information on data- attributes.

Alternatively you can use render method, detect filtering event (type == 'filter') and return desired value instead. See my answer to similar question for an example.

Upvotes: 1

Related Questions