Incorrect option values - Individual column searching (select inputs)
Incorrect option values - Individual column searching (select inputs)
Hello,
The select inputs on my table are being muddled as I have an <a href="">
link in my table cell.
This is what is being generated by datatables for the option:<option value="<a href=" "="" id="horse" data-reveal-id="myModal">Kings Gold">Kings Gold</option>
as you can see it is including the links.
and this is what my code looks like <td data-label="horse"><a href="" id="horse" data-reveal-id="myModal">'.$v->horsename.'</a></td>
How can I ignore the <a href="">
so it just displays the table cell value and hence it works correctly?
I'm using the code from the page: https://datatables.net/examples/api/multi_filter_select.html
`$(document).ready(function() {
$('#example').DataTable( {
initComplete: function () {
this.api().columns().every( function () {
var column = this;
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.footer()).empty() )
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );
column.data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' )
} );
} );
}
} );
} );`
Answers
I have the same issue. Here is a snippet of my code:
The column selector pulldown shows me the Element+ "> +Element
For example, if my element is 'BRIsat', the pulldown will show me 'BRIsat">BRIsat'.
Most frustratingly, it will NOT find the item I am filtering because there is to item by that name.
Any help would be much appreciated.
You can use my yadcf for column filters, it got quite a powerfull parsing abilitys of column cells, see example on the last column in the showcase and read about the
column_data_type
andhtml_data_type
in the docs