Feature - searchPane: State saving integration

pull/355/head
Allan Jardine 7 years ago
parent 1eb23d9c82
commit 130178932d

@ -2,7 +2,7 @@
// - Styling for selected // - Styling for selected
// - Styling for container / header // - Styling for container / header
// - Styling for clear option // - Styling for clear option
// - State saving integration // - Rebuild API method
(function(factory) { (function(factory) {
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
@ -72,8 +72,6 @@
container( this.s.dt ) : container( this.s.dt ) :
container; container;
console.log( host );
if ( this.c.insert === 'prepend' ) { if ( this.c.insert === 'prepend' ) {
$(this.dom.container).prependTo( host ); $(this.dom.container).prependTo( host );
} }
@ -130,10 +128,9 @@
// On initialisation, do we need to set a filtering value from a // On initialisation, do we need to set a filtering value from a
// saved state or init option? // saved state or init option?
var search = column.search(); var search = column.search();
search = search = search
search.length && search[0] ? search.substr(1, search.length - 2).split('|')
? search[0].substr(1, search[0].length - 2).split('|') : [];
: [];
var data = column var data = column
.data() .data()
@ -154,8 +151,12 @@
.html(bins[data[i]]) .html(bins[data[i]])
); );
if ($.inArray(data[i], search) !== -1) { if ( search.length ) {
li.addClass(itemClasses.selected); var escaped = $.fn.dataTable.util.escapeRegex( data[i] );
if ($.inArray(escaped, search) !== -1) {
li.addClass(itemClasses.selected);
}
} }
list.append(li); list.append(li);
@ -207,9 +208,9 @@
table table
.column(pane.data('column')) .column(pane.data('column'))
.search( .search(
$.map(filters, function(filter) { '^'+$.map(filters, function(filter) {
return $.fn.dataTable.util.escapeRegex( $(filter).data('filter') ); return $.fn.dataTable.util.escapeRegex( $(filter).data('filter') );
}).join('|'), }).join('|')+'$',
true, true,
false false
) )

@ -23,7 +23,8 @@ body {
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(document).ready( function () { $(document).ready( function () {
$('#example').DataTable( { $('#example').DataTable( {
searchPane: true searchPane: true,
stateSave: true
} ); } );
} ); } );
</script> </script>

Loading…
Cancel
Save