Configure selectAll button to select only the rows in current page
Configure selectAll button to select only the rows in current page
kumarnishant342
Posts: 7Questions: 4Answers: 0
We are using Pagination in our datatable. I need to provide a way to select all the rows in current page.
Can we configure selectAll button (https://datatables.net/reference/button/selectAll) provided by DataTable to do this instead of selecting all the rows in our datatable ?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @kumarnishant342 ,
Yep, you can create a custom button like this to select all rows on the current page.
Cheers,
Colin
Thanks @colin, it worked! Just for information of other readers, if we want to deselect all the rows on current page, we can use
table.rows({page: 'current'}).deselect();
in our action.Pretty awesome!
Mix of both last comments
buttons: [
{
text: '<i class="far fa-check-square"></i>',
titleAttr: 'select all',
action: function() {
table.rows({
page: 'current'
}).select();
}
},
{
text: '<i class="far fa-square"></i>',
titleAttr: 'unselect all',
action: function() {
table.rows({
page: 'current'
}).deselect();
}
}
],
Hi i want to implement the same feature in the Angular datatable which is based you datatables.net
https://l-lin.github.io/angular-datatables/#/getting-started
Could anyone suggest me how can I achieve that. @colin @zarza
@sameeralikhan There are a few threads on Angular, such as this one, so I'd suggest scanning the forum. If no joy, I'd suggest opening a new thread since this one isn't really applicable.
Colin
Hi @colin will do thanks