How to delete a row and redraw to correct zebra striping

How to delete a row and redraw to correct zebra striping

CDeCinkoCDeCinko Posts: 19Questions: 9Answers: 1

I am able to execute an ajax method that deletes a item from the database. The success correctly removes the row from the table. However, the zebra striping is left incorrect and not redrawn. I have tried several different ways and either the stripes do not correct or two rows are deleted from the DataTable.

$.ajax({
    type: "get",
    url: "/Admin/RemoveSubscriber/?listName=" + listName + "&userName=" + userName,
    data: "",
    success: function () {
        $(row).fadeOut(200, function () {
            $(row).remove();
            //table
            //    .row()
            //    .remove(table.row().index(row))
            //    .draw();
            table
                .row($(row).parents('tr'))
                .remove()
                .draw();
        });
    }

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin
    Answer ✓

    You can't use fadeOut on a table row I don't think I'm afraid. You have to use row().remove() directly. If you do so, does it work as expected?

    Allan

  • CDeCinkoCDeCinko Posts: 19Questions: 9Answers: 1

    I figured it out. Seems I needed to move $row into the .row() portion as I had it in the .remove() part. As for the fadeout, it works either way, just not sure the fadeout is visible enough to really do anything, might be unnecessary as the redraw, at least on my small test dataset, is pretty smooth.

    success: function () {
        $(row).fadeOut(200, function () {
            table
                .row($row)
                .remove()
                .draw();
        });
    }
    
This discussion has been closed.