Is it possible keep rows selected when using ajax.reload()?

Is it possible keep rows selected when using ajax.reload()?

GolnazGolnaz Posts: 23Questions: 5Answers: 0

Hi,

I modified the example in

https://datatables.net/examples/api/select_row.html

To select more than one row and delete them. Please see my modified code below

 $('#example tbody').on( 'click', 'tr', function () {
        if ( $(this).hasClass('selected') ) {
            $(this).removeClass('selected');
        }
        else {
            table.$('tr.selected');//.removeClass('selected');
            $(this).addClass('selected');
        }
    } );
    $('#delete').click( function () {
        table.rows('.selected').remove().draw( false );
    } );

However, I also use ajax.reload to update my rows. But when using ajax.reload(), my selection will disappear. Is there a way to keep selected rows when I am using ajax.reload().

Many thanks,
Golnaz

Answers

Sign In or Register to comment.