select only rows in the visible part of the table

select only rows in the visible part of the table

MaikelMaikel Posts: 56Questions: 14Answers: 1

Hey,

i have buttons like 'select all', 'deselect all', 'invert selection'
but i want these buttons to only work on the visible part of the tables, so after filtering and paging.

How do i do this?

Maikel

Replies

  • kthorngrenkthorngren Posts: 6,315Questions: 21Answers: 1,383

    Maybe something this will work in your button config:

    exportOptions: {
      rows: ':visible'
    }
    

    Kevin

  • MaikelMaikel Posts: 56Questions: 14Answers: 1

    what i currently have:

                    select: {
                        info:     true,
                        style:    'os',
                        selector: 'td:not(:has(div.details-control), .details-control), th'
                    },
    

    i tried adding :visible in there but it doesn not seem to work

  • allanallan Posts: 50,303Questions: 1Answers: 7,478 Site admin

    You'll need a custom button to do what you are looking for. Something like:

    {
      text: "Select visible",
      action: function ( dt ) {
        dt.rows( { page: 'current' } ).select();
      }
    }
    

    What Kevin was looking at was when exporting data with buttons such as excel.

    Allan

  • eJedeJed Posts: 1Questions: 0Answers: 0
    edited July 2018

    I had to modify allans code to get it to work. I'm not a javascript expert but maybe it will help someone.

    {
        text: "Select Page",
        action: function ( e, dt, button, config ) {
            dt.rows( { page: 'current' } ).select();
        }
    },
    
  • allanallan Posts: 50,303Questions: 1Answers: 7,478 Site admin

    Doh! I forgot about the e parameter. Thanks for pointing that out.

    Allan

  • shujaatkulvishujaatkulvi Posts: 1Questions: 0Answers: 0

    Thnx eJed. It works like magic :smiley:

Sign In or Register to comment.