Unable to get datatable to refresh
Unable to get datatable to refresh
smarthomes
Posts: 14Questions: 5Answers: 0
I am unable to get my data tables to refresh after I update the tables. Everything works except the refresh.
I have been working on this for longer than I can to admit. Any ideas? The params I am passing are static for now to ease in the debugging...
'''
jQuery(document).ready(function() {
var selected_table = $('#selected_items').dataTable({
"ajax": '/cfcs/db_items.cfc?method=getSelectedItems',
"columns": [{
"visible": false,
"orderable": false,
},{
"orderable": true
}, {
"orderable": true
}, {
"orderable": true
}, {
"orderable": true
}],
"paging": false,
"info": false,
"searching": false
});
var unselected_table = $('#unselected_items').dataTable({
"ajax": '/cfcs/db_items.cfc?method=getUnselectedItems',
"columns": [{
"visible": false,
"orderable": false,
"searchable": false
},{
"orderable": true,
"searchable": true
}, {
"orderable": true,
"searchable": true
}, {
"orderable": true,
"searchable": false
}, {
"orderable": true,
"searchable": false
}]
});
unselected_table.on('click', 'tr' ,function() {
$.ajax({
type: "post",
url: "/cfcs/db_items.cfc?method=insertItemToPackage",
data: {
"pid": "16",
"iid": "5"
},
success: function(){
$('#item_package_message').html("Item added to package").show().delay(2000).fadeOut();
$('#selected_items').dataTable().api().ajax.reload();
$('#selected_items').dataTable().api().draw();
},
error: function(){
alert("Error");
}
});
});
selected_table.on('click', 'tr' ,function() {
$.ajax({
type: "post",
url: "/cfcs/db_items.cfc?method=deleteItemFromPackage",
data: {
"pid": "16",
"iid": "5"
},
success: function(){
$('#item_package_message').html("Item removed from package").show().delay(3000).fadeOut();
$('#unselected_items').dataTable().api().ajax.reload();
$('#unselected_items').dataTable().api().draw();
},
error: function(){
alert("Error");
}
});
});
});
'''
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Try replacing that with just:
The selected table is updating the unselected table and likewise the unselected table is updating the selected table. is that correct?
Allan
Allan,
That is correct. I will try that ASAP.