How to disable search for one column of a table
How to disable search for one column of a table
I have one table in which my first column contains radio button and last column contains a href link.
I have used below code to highlight the search text:
$(document).ready(function() {
$('#tableAllScripts').dataTable( {
"iDisplayLength": 10000,
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var settings = this.fnSettings();
var str = settings.oPreviousSearch.sSearch;
$('td', nRow).each( function (i) {
this.innerHTML = aData[i].replace( new RegExp( str, 'i'), function(matched) { return ""+matched+"";} );
} );
return nRow;
},
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] },
{ "bSearchable": false, "aTargets": [ 0 ] }
],
} );
} );
however when i search through input it shows html element code in the table. To avoid this situation i want to disable search on first and last column.
It would be great if someone can help me out with a solution. Thanks in advance
I have used below code to highlight the search text:
$(document).ready(function() {
$('#tableAllScripts').dataTable( {
"iDisplayLength": 10000,
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var settings = this.fnSettings();
var str = settings.oPreviousSearch.sSearch;
$('td', nRow).each( function (i) {
this.innerHTML = aData[i].replace( new RegExp( str, 'i'), function(matched) { return ""+matched+"";} );
} );
return nRow;
},
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] },
{ "bSearchable": false, "aTargets": [ 0 ] }
],
} );
} );
however when i search through input it shows html element code in the table. To avoid this situation i want to disable search on first and last column.
It would be great if someone can help me out with a solution. Thanks in advance
This discussion has been closed.
Replies
*edit* I see that you are. If that isn't working, please link to a test case showing the error so we can debug and resolve it.
Allan