Highlight term returned from search

Highlight term returned from search

yhbrandonyhbrandon Posts: 1Questions: 0Answers: 0
edited February 2012 in DataTables 1.8
Im hoping that someone could help me out on this issue I'm having with trying to highlight a value in a column once it is returned from a search. Basically I have three columns to my datatable, Name, type, and an action field. Once a user search for a particular name, all items with that name are returned in the table. I want to be able to highlight the name that is return from the search in the name column. So basically every name will be highlighted. This is what I'm during currently without much success. Any help would be greatly appreciated.
[code]
$('#TBLfindDict').dataTable({
"iDisplayLength": 100,
"sPaginationType": "full_numbers",
"bLengthChange": false,
"bFilter": false,
"bJQueryUI": true,
"sAjaxSource": /path/,
"sAjaxDataProp": "data",
"fnRowCallback": function(data, iDisplayIndex, iDisplayIndexFull){
var txt = $('#txtHighlight').val();
var txtRegex = new RegExp(txt, "g");
$('#results .termFlag').each(function(){
$(this).html($(this).html().replace(txtRegex, '' + txt + ''));
});

return data;
},
"aoColumns": [

{ "mDataProp": "name" },
{ "mDataProp": "type" },
{ "mDataProp": "id",
"bSortable": false,
"fnRender": function ( oObj ) {
return /path/;
}
}
],
"oLanguage": {
"sZeroRecords": "No Records",
"sInfo": "_START_-_END_ of _TOTAL_"
}
});[/code]

Replies

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin
    Have a look at this post, which shows one way how this feature could be implemented: http://datatables.net/forums/discussion/8370/upgrading-from-1.8-1.9-issues#Item_2

    Allan
This discussion has been closed.