Missing items in drop down on individual column searching (select inputs) and server-side processing

Missing items in drop down on individual column searching (select inputs) and server-side processing

deetimbadeetimba Posts: 5Questions: 2Answers: 0
edited November 2017 in Free community support

Hi there,

I added "Individual column searching (select inputs)" while using server side processing. It seems to work nicely, but I encountered the issue that the drop downs are only loading some data but not all.

Means, I have a database connected with ~50k rows. One column is called country. the drop down shows "Austria" only, which is the country of the first couple of hundreds rows but not loading any of the other countries after. Also not, of course not dynamically when I scroll down.

My question is now, how I can assure that all available countries are added to the drop down when I load the page and how can I prevent some columns to have a drop down box at all (50k unique items do not have to be added to a drop down of course).

Can anyone propose an approach or provide a link to another thread? I could not find the appropriate info in the forum or on the DT page.

Would appreciate it a lot. Thanks


$(document).ready(function() {
$('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "../server_side/scripts/server_processing.php",
"scrollY": "550px",
"scrollX": true,
"scroller": {loadingIndicator: false },
"scrollCollapse": true,
"paging": true,
"select": true,
dom: 'Bfrtip',
buttons: ['copy', 'csv', 'excel', 'pdf', 'print'] ,
"searching": true,
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(this.value)
.draw();
} );
column.data().unique().sort().each( function ( d, j ) {
if(column.search() === '^'+d+'$'){
select.append( '<option value="'+d+'" selected="selected">'+d+'</option>' )
} else {
select.append( '<option value="'+d+'">'+d+'</option>' )
}
} );
} );
}
} );
} );

This discussion has been closed.