Best way to remove unselected rows

Best way to remove unselected rows

PennywisePennywise Posts: 15Questions: 3Answers: 1

I have a table where clicking a button removes selected rows. My code for that is:

``` $('#cutSelectedButton').click(function () {
var table = $('#homeTable').DataTable();
var rows = table.rows('.selected').remove().draw();

        });    

However, I would also like to have another button that removes only those rows that AREN'T selected. What is the best way of accomplishing this?

Answers

  • PennywisePennywise Posts: 15Questions: 3Answers: 1

    I seemed to have solved this by toggling my unselected rows to selected and my selected rows to unselected and then removing selected rows as follows:

            $('#cropSelectedButton').click(function () {
                table.$('tr').toggleClass('selected');
                table.rows('.selected').remove().draw();
                }
            );
    
This discussion has been closed.