0

I am using Angular Datatables in one of the application and have used the select extension as specified in the documentation like the following:

<table class="table animate__animated animate__fadeIn" datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger" [id]="tableId">

</table>

and the options are defined as follows:

    this.dtOptions = {
        info: false,
        order: [],
        select: true,
        dom: 'Bfrtip',
        buttons: [
            'selectAll',
            'selectNone'
        ]
    };
} 

Now the select functionality is working fine, but I need to get the selected rows when I click on a button. How can I do this ? Is there any option in the Datatables API for accessing selected rows ?

Documentation - https://l-lin.github.io/angular-datatables/#/extensions/select

In the core datatables, there is an option for adding the action callback. But not sure whether it will work with selectAll

2

1 Answer 1

1
  1. Get selected rows:

myTable.rows({ selected: true })

  1. Get data of selected rows:

myTable.rows({ selected: true }).data()

  1. Get id's os selected rows (For this is usefull use rowId and ajax) :

myTable.rows({ selected: true }).ids()

And then with this information, stored in a variable, you can iterate, filter... etc.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.