trouble deleting rows by id

trouble deleting rows by id

mihomesmihomes Posts: 165Questions: 23Answers: 0
edited January 2014 in General
Can't seem to remove rows by their ID.
[code]
$.each( selected, function( index, value ) {
DT.fnDeleteRow( document.getElementById( '"'+value+'"' ) );
console.log('"'+value+'"');
});
DT.fnDraw();
[/code]

selected is an array... I have verified with console log that value is in the format "187421" where exists in the current table's display.

DT is the variable I set = to my table.

[code]
var DT = $('#sample_1').dataTable({
... table stuff
});
[/code]

Replies

  • mihomesmihomes Posts: 165Questions: 23Answers: 0
    Why in the world does this not work? Just selecting one row to delete for this example.

    console.log(value); = 187422
    console.log(something); =

    which are both valid, however, the row is not removed from the table.


    [code]
    $.each( selected, function( index, value ) {
    var something = document.getElementById(value)
    $('#sample_1').dataTable().fnDeleteRow(something, null, false);
    console.log(something);
    console.log(value);
    });
    $('#sample_1').dataTable().fnDraw();
    [/code]
  • allanallan Posts: 63,302Questions: 1Answers: 10,431 Site admin
    Looks okay to me: http://live.datatables.net/onugif/edit#javascript,html - After 1 second the "Firefox 1.0" row will be removed.

    Are you using server-side processing perhaps? fnDeleteRow is a client-side function, so will have no effect on server-side processing tables, since the data is at the server.

    Allan
  • mihomesmihomes Posts: 165Questions: 23Answers: 0
    haha... I think I missed that part in the examples and documentation. I was just trying to save a call to the db by deleting the row instead of using fnDraw after my db changes.
This discussion has been closed.