Select filter only shows first pages unique data
Select filter only shows first pages unique data
I am using datatables with ajax-datatables-rails in my Rails 4 site. The table is working beautifully, but it currently only shows selectable unique data from the first page (10 results per page). I would like to show all but cannot find any documentation on this, which is needed due to my lack of proficiency with javascript.
I've also switched from the coffeescript file to in-page javascript due to an issue with coffeescript not liking the ", true, false" bit on line 16. Still not working though. Here is the javascript in my index view:
$(document).ready(function() {
$('#search-table').DataTable( {
processing: true,
serverSide: true,
ajax: $('#search-table').data('source'),
initComplete: function () {
this.api().columns().every( function () {
var column = this;
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.footer()).empty() )
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );
column.data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' )
} );
} );
}
} );
} );