Merge pull request #287 from mdeniz/add_column_search_highlight

Feature - search highlight: Add column search/filtering highlight
pull/288/head
Allan Jardine 9 years ago committed by GitHub
commit b61bc6bbc1

@ -2,5 +2,10 @@
table.dataTable span.highlight { table.dataTable span.highlight {
background-color: #FFFF88; background-color: #FFFF88;
border-radius: 0.28571429rem;
} }
table.dataTable span.column_highlight {
background-color: #ffcc99;
border-radius: 0.28571429rem;
}

@ -43,10 +43,16 @@ function highlight( body, table )
// Don't highlight the "not found" row, so we get the rows using the api // Don't highlight the "not found" row, so we get the rows using the api
if ( table.rows( { filter: 'applied' } ).data().length ) { if ( table.rows( { filter: 'applied' } ).data().length ) {
table.columns().every( function () {
var column = this;
column.nodes().flatten().to$().unhighlight({ className: 'column_highlight' });
column.nodes().flatten().to$().highlight( $.trim( column.search() ).split(/\s+/), { className: 'column_highlight' } );
} );
body.highlight( $.trim( table.search() ).split(/\s+/) ); body.highlight( $.trim( table.search() ).split(/\s+/) );
} }
} }
// Listen for DataTables initialisations // Listen for DataTables initialisations
$(document).on( 'init.dt.dth', function (e, settings, json) { $(document).on( 'init.dt.dth', function (e, settings, json) {
if ( e.namespace !== 'dt' ) { if ( e.namespace !== 'dt' ) {

Loading…
Cancel
Save