Configure selectAll button to select only the rows in current page

Configure selectAll button to select only the rows in current page

kumarnishant342kumarnishant342 Posts: 7Questions: 4Answers: 0
edited August 2018 in Free community support

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

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    edited September 2018 Answer ✓

    Hi @kumarnishant342 ,

    Yep, you can create a custom button like this to select all rows on the current page.

    Cheers,

    Colin

  • kumarnishant342kumarnishant342 Posts: 7Questions: 4Answers: 0

    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.

  • zarzazarza Posts: 7Questions: 3Answers: 0

    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();
    }
    }
    ],

  • sameer1319sameer1319 Posts: 5Questions: 1Answers: 0

    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

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    @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

  • sameer1319sameer1319 Posts: 5Questions: 1Answers: 0

    Hi @colin will do thanks

This discussion has been closed.