Search code examples
c#asp.net-mvcdatatablestabletools

jquery datatables tablestools delete remove


today i have the following question: I use in my mvc webapplication the jquery datatables and tabletools. Now i can select or deselect the rows of my table, but i can't remove the selected rows. Here is a snippet:

dom: 'T<"clear">lfrtip',
            tableTools: {
                "sRowSelect": "os",
                "aButtons": ["select_all", "select_none"]                
             },

I am looking for an aButton like "remove" or "delete", but there is no one. How is it possible to remove or delete the selected row? My webapplication is connected with an sql database.

Please give me a solution.

Thanks.

Greetz Vegeta


Solution

  • You need something like this (and yes, I know it's not #c, so you'll have to adapt it.):

    Assuming you have selecting working correctly. This will function will remove the rows that are selected.

    var table = $('#example').DataTable();
    $('#button').click( function () {
            table.row('.selected').remove().draw( false );
        } );