After deleting row from datatable, the datatable cannot update
After deleting row from datatable, the datatable cannot update
When i delete the row from datatable, the data rows are not refresh (still exist the deleted one).
but the row had been deleted in mysql database.
first of all this is my jscript import
[code]
[/code]
This is what i initialized.
[code]
$(document).ready(function(){
var oTable = $('#editable').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
}).makeEditable({
sDeleteURL: "CRUD/DepDelete.php",
fnOnDeleted: function() {
oTable.fnDraw(false)
},
oDeleteRowButtonOptions:{
label: "Remove",
},
fnShowError: function (message, action){
switch (action) {
case "delete":
jAlert(message, "Delete");
break;
}
},
});
});
[/code]
This is how my table looks alike
[code]
Delete
DeptName
CDate
DeptName
CDate
<?php
while ($row = mysql_fetch_assoc($alldeptresult))
{
?>
<?php echo $row['DeptName']; ?>
<?php echo $row['CDate']; ?>
<?php
}
?>
[/code]
Pls, help me...
but the row had been deleted in mysql database.
first of all this is my jscript import
[code]
[/code]
This is what i initialized.
[code]
$(document).ready(function(){
var oTable = $('#editable').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
}).makeEditable({
sDeleteURL: "CRUD/DepDelete.php",
fnOnDeleted: function() {
oTable.fnDraw(false)
},
oDeleteRowButtonOptions:{
label: "Remove",
},
fnShowError: function (message, action){
switch (action) {
case "delete":
jAlert(message, "Delete");
break;
}
},
});
});
[/code]
This is how my table looks alike
[code]
Delete
DeptName
CDate
DeptName
CDate
<?php
while ($row = mysql_fetch_assoc($alldeptresult))
{
?>
<?php echo $row['DeptName']; ?>
<?php echo $row['CDate']; ?>
<?php
}
?>
[/code]
Pls, help me...
This discussion has been closed.
Replies
The row in the database is removed, but the dataTable view is not refreshed and the deleted row still shows.
I tried johnadamsy's suggestion, but no luck.
Has anyone managed to find a solution to this problem?
Thanks.
and (your primary key probably) > (DT_RowId) that can't be found in the table
Here is my solution in datatablesEditable.js file
//I add extra lines to this function to try delete visible row by DT_RowId
[code]
$(".table-action-deletelink", oTable).live("click", function (e)
{
....
var aPos = oTable.fnGetPosition(this.parentNode);//ana düğümü elde et! (get the parent node)
// I defined here new variable named tablo_row_id
var tablo_row_id=aPos[0];//şimdi de DT_Row'anahtarını bul (get the DT_RowId)
if (properties.fnOnDeleting(oTD, id, fnDeleteRow)) {
fnDeleteRow(id, sURL,tablo_row_id);//bu değerleri silme işlevine gönder (send these parameters to deleting function)
....
}
//Please add new parameter to deleting function
function fnDeleteRow(id, sDeleteURL,tablo_row_id)
{
...
$.ajax({ 'url': sURL,
'type': properties.sDeleteHttpMethod,
'data': data,
// başarı kısmından sonra satırı sil (delete row after success)
"success": function (response) {
oTable.fnDeleteRow(tablo_row_id)//burada satırı görünürden sil (delete visible row)
fnOnRowDeleted; }
...
}
[/code]
Hope this helps !