After deleting row from datatable, the datatable cannot update

After deleting row from datatable, the datatable cannot update

coemawcoemaw Posts: 4Questions: 0Answers: 0
edited January 2012 in General
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...

Replies

  • johnadamsyjohnadamsy Posts: 13Questions: 0Answers: 0
    Try change: [code]fnOnDeleted: function() {oTable.fnDraw(false)},[/code] to [code]fnOnDeleted: function() {oTable.fnDraw(true)},[/code]
  • glennSuperdudeglennSuperdude Posts: 1Questions: 0Answers: 0
    edited June 2012
    I have also found the same problem.
    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.
  • imanerdimanerd Posts: 6Questions: 0Answers: 0
    I'm also having the same problem. Been searching all day for a solution :o(
  • tacturcotacturco Posts: 4Questions: 0Answers: 0
    edited October 2012
    I think the problem is casued by jqueryDataTables DT_RowId is not matching with the MysqlDatatables primary key (if you're using autoincrement and for some reasons and you deleted row in mysql table e.g manually by using Navicat). Datatableseditable.js file tries to delete row by id (mysql primary key)
    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 !
  • coemawcoemaw Posts: 4Questions: 0Answers: 0
    edited January 2013
    Got it ! Thanks
This discussion has been closed.