Table not ReDrawing after deletion of multiple rows
Table not ReDrawing after deletion of multiple rows
Hi,
I am deleting multiple rows using datatables and I am coming across an issue whereby the rows in the front end table are not being deleted every time. This does not happen consistently - it depends on the number of rows I delete.
My code is as follows:
I have an onclick event when delete button is clicked and this will delete the records from the database. I then pass the array of pos and attempt to delete these from the front end by looping over the pos in array.
//add event handler for when delete rows is clicked
$('#deleteMoves').click(function(){
//Send array to server to processing
if(rowsSelected.length > 0){
var changeIds = rowsSelected;
changeIds = "changeIds=" + rowsSelected[0];
for(counter = 1; counter < rowsSelected.length; counter++){
changeIds += "&changeIds=" + rowsSelected[counter];
}
$.ajax({
url: "/json/moves/deleteMoves.json",
data: changeIds,
success: function(data){
deleteRows();
oTable.fnDraw();
},
failure: function(errMsg) {
alert("Error Occurred. No Rows Were Deleted.");
}
});
}else{
alert("No Rows Selected");
}
});
function deleteRows(){
for(posCounter = 0; posCounter < posList.length; posCounter++){
oTable.fnDeleteRow(posList[posCounter]);
}
//clear out arrays
posList = [];
rowsSelected = [];
}//end deleteRows func
Please help - am new to Datatables and need this asap! This may be something very simple but I am not getting it !
Thanks in advance
I am deleting multiple rows using datatables and I am coming across an issue whereby the rows in the front end table are not being deleted every time. This does not happen consistently - it depends on the number of rows I delete.
My code is as follows:
I have an onclick event when delete button is clicked and this will delete the records from the database. I then pass the array of pos and attempt to delete these from the front end by looping over the pos in array.
//add event handler for when delete rows is clicked
$('#deleteMoves').click(function(){
//Send array to server to processing
if(rowsSelected.length > 0){
var changeIds = rowsSelected;
changeIds = "changeIds=" + rowsSelected[0];
for(counter = 1; counter < rowsSelected.length; counter++){
changeIds += "&changeIds=" + rowsSelected[counter];
}
$.ajax({
url: "/json/moves/deleteMoves.json",
data: changeIds,
success: function(data){
deleteRows();
oTable.fnDraw();
},
failure: function(errMsg) {
alert("Error Occurred. No Rows Were Deleted.");
}
});
}else{
alert("No Rows Selected");
}
});
function deleteRows(){
for(posCounter = 0; posCounter < posList.length; posCounter++){
oTable.fnDeleteRow(posList[posCounter]);
}
//clear out arrays
posList = [];
rowsSelected = [];
}//end deleteRows func
Please help - am new to Datatables and need this asap! This may be something very simple but I am not getting it !
Thanks in advance
This discussion has been closed.