DataTables fnFilter column on img filename

I am trying to filter a column based on the image file name in the src attribute of a tag.

My line looks like this:

<tr class="unread odd"> <td class=" "><input type="checkbox" name="r28416" value="1"></td> <td class=" "><img src="img/icons/bullet_yellow.png" alt="A" title="A"></td> <td class="nw ">Non-Lu</td> <td class=" "><a class="fancybox" href="tpl/laboratoires/details.php?id=28416">J9121702</a></td> <td class=" ">Data</td> <td class=" ">378192</td> <td class=" ">John Doe</td> <td class=" ">DOEJ54161235</td> <td class="nw sorting_1">2012-07-12 12:02</td> <td class=" ">0</td> <td class=" ">40</td> 

I use this line as a filter:

 table.fnFilter( "bullet_yellow", 1 ); 

Each different class works, and I have different filters for another column. Just doesn't work with that. ANY thoughts?

+6
source share
2 answers

This worked for me when I just added some text to filter in the span with display:none .

  <td class=" "> <img src="img/icons/bullet_yellow.png" alt="A" title="A"> <span style="display:none;">bullet_yellow</span>` </td> 
+4
source

Perhaps try putting src in a hidden column and then use that column for sorting / filtering. I had to sort by a different column because my second column was converted to images.

 aoColumns: [ {"sType": "html", "bSortable": true}, {"iDataSort": 2, "bSortable": true, "bUseRendered":false}, {"bVisible": true, "sType": "numeric"} ] 
0
source

Source: https://habr.com/ru/post/920346/


All Articles