Server Side select from dropdown doesn't update
Server Side select from dropdown doesn't update
channie49
Posts: 1Questions: 1Answers: 0
Hi there,
First of all I am sorry for any stupid mistakes I am a newbie. I've recently changed the way the table grabs the data and the dropdown selection doesn't work anymore. I see the list but it won't reload no matter what.
I've got a simple table and here is the code I was using until recently:
$(document).ready(function() {
var dataTable = $(\'#userList\').DataTable( {
"processing": true,
"ordering": true,
"order": [0, "desc"],
"serverSide": true,
"columnDefs": [{
"targets": [5, \'no-sort\'],
}],
"ajax":{
url :"table.php",
type: "post",
error: function(){
$(".userList-error").html("");
$("#userList-grid").append(\'<tbody class="userList-error"><tr><th colspan="6">No data found in the server</th></tr></tbody>\');
$("#userList_processing").css("display","none");
}
},
initComplete: function () {
var api = this.api();
api.columns().indexes().flatten().each( function ( i ) {
var column = api.column( i );
if (i == 4)
{
var select = $(\'<select><option value=""></option></select>\')
.appendTo( $(column.header()) )
.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>\' )
} );
}
} );
}
} );
Any ideas what I'm doing wrong?
This discussion has been closed.
Answers
Hi @channie49 ,
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin