Filter Highlighting - Filter &
Filter Highlighting - Filter &
Hi,
im using this code from this Forumpost to highlight the filtered data. which means if i type "as" it highlights all "as" in the table.
works fine so far. but if i search for "nb" or "am". the script makes also the "&" and " " visible and higlighted. how can i modify the regex or something else so it ignores these expressions? Because in the table i have things like "Multi & Media" which the script does to: "Multi & Media if i type in "am"
http://live.datatables.net/ukapoc/10 <-- in this case he don't finds the amp when tiping "am"... but he shows & if i search for &... i dont get it...its the same code as mine O.o
Here is the fiddle, but i don't know how to make it complete work :/
http://jsfiddle.net/exk9h/1/
[code]
// HIGHLIGHT FCT
jQuery.fn.dataTableExt.oApi.fnSearchHighlighting = function(oSettings) {
// Initialize regex cache
oSettings.oPreviousSearch.oSearchCaches = {};
oSettings.oApi._fnCallbackReg( oSettings, 'aoRowCallback', function( nRow, aData, iDisplayIndex, iDisplayIndexFull) {
// Initialize search string array
var searchStrings = [];
var oApi = this.oApi;
var cache = oSettings.oPreviousSearch.oSearchCaches;
// Global search string
// If there is a global search string, add it to the search string array
if (oSettings.oPreviousSearch.sSearch) {
searchStrings.push(oSettings.oPreviousSearch.sSearch);
}
// Individual column search option object
// If there are individual column search strings, add them to the search string array
if ((oSettings.aoPreSearchCols) && (oSettings.aoPreSearchCols.length > 0)) {
for (var i in oSettings.aoPreSearchCols) {
if (oSettings.aoPreSearchCols[i].sSearch) {
searchStrings.push(oSettings.aoPreSearchCols[i].sSearch);
}
}
}
// Create the regex built from one or more search string and cache as necessary
if (searchStrings.length > 0) {
var sSregex = searchStrings.join("|");
if (!cache[sSregex]) {
var regRules = "("
, regRulesSplit = sSregex.split(' ');
regRules += "("+ sSregex +")";
for(var i=0; i
im using this code from this Forumpost to highlight the filtered data. which means if i type "as" it highlights all "as" in the table.
works fine so far. but if i search for "nb" or "am". the script makes also the "&" and " " visible and higlighted. how can i modify the regex or something else so it ignores these expressions? Because in the table i have things like "Multi & Media" which the script does to: "Multi & Media if i type in "am"
http://live.datatables.net/ukapoc/10 <-- in this case he don't finds the amp when tiping "am"... but he shows & if i search for &... i dont get it...its the same code as mine O.o
Here is the fiddle, but i don't know how to make it complete work :/
http://jsfiddle.net/exk9h/1/
[code]
// HIGHLIGHT FCT
jQuery.fn.dataTableExt.oApi.fnSearchHighlighting = function(oSettings) {
// Initialize regex cache
oSettings.oPreviousSearch.oSearchCaches = {};
oSettings.oApi._fnCallbackReg( oSettings, 'aoRowCallback', function( nRow, aData, iDisplayIndex, iDisplayIndexFull) {
// Initialize search string array
var searchStrings = [];
var oApi = this.oApi;
var cache = oSettings.oPreviousSearch.oSearchCaches;
// Global search string
// If there is a global search string, add it to the search string array
if (oSettings.oPreviousSearch.sSearch) {
searchStrings.push(oSettings.oPreviousSearch.sSearch);
}
// Individual column search option object
// If there are individual column search strings, add them to the search string array
if ((oSettings.aoPreSearchCols) && (oSettings.aoPreSearchCols.length > 0)) {
for (var i in oSettings.aoPreSearchCols) {
if (oSettings.aoPreSearchCols[i].sSearch) {
searchStrings.push(oSettings.aoPreSearchCols[i].sSearch);
}
}
}
// Create the regex built from one or more search string and cache as necessary
if (searchStrings.length > 0) {
var sSregex = searchStrings.join("|");
if (!cache[sSregex]) {
var regRules = "("
, regRulesSplit = sSregex.split(' ');
regRules += "("+ sSregex +")";
for(var i=0; i
This discussion has been closed.