Question about selectPage checkbox behavior

Question about selectPage checkbox behavior

kthorngrenkthorngren Posts: 21,450Questions: 26Answers: 4,975

See the Current page selection only example and follow these steps:

  1. Click Select All to select all on the page
  2. Go to page two and select a row
  3. There are 11 rows selected and the intermediate state is shown
  4. Go back to page 1 and click Select All
  5. Nothing happens - I expected all selected rows to become unselected

What is the expected behavior?

Kevin

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Yeah, there's something very odd there. I'd say when you Select All on page 1, when you go to any other page, all rows should still be selected. As it stands, those other selections are being cleared - it's not just a display issue, as rows() agrees with it too:

    $('#example').DataTable().rows({selected: true}).count()
    10
    

    II've raised it internally (DD-2979 for my reference) and we'll report back here when there's an update. I'll add a unit test for this too, it looks like it was missed,

    Cheers,

    Colin

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    Hmmm - the header checkbox is configured to operate only on the page, so yes, I guess it should deselect the current page if all rows are selected on it. Following through on that, it should show as checked when all rows on the current page are selected. However, the state of the checkbox at the moment is only based on all rows, across all pages.

    I don't really like the header checkbox state being based on the current page only - that doesn't seem to make much sense, but it is how it is configured...

    For a configuration value of select-page the current behaviour could be argued to be correct (select page, status global), but a value of page could be used for the current page control only.

    What a horrible set of edge cases that one little option introduces!

    Allan

  • kthorngrenkthorngren Posts: 21,450Questions: 26Answers: 4,975

    This test case shows how the Gyrocode checkboxes handles select all on current page only.
    https://live.datatables.net/tilarisu/1/edit

    Looks like it keeps the header checkbox status on a per page basis.

    Kevin

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    Nice example - many thanks Kevin! I think that probably makes most sense given the option in question. I'll look at getting that done when DT 2.1 is finished.

    Allan

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Sorry, Kevin, totally ignore my comment above - I missed the point that your comment (and the example) were demonstrating single page selection. I must stop replying to forum posts until the coffee has kicked in...

  • kthorngrenkthorngren Posts: 21,450Questions: 26Answers: 4,975
    edited June 25

    No worries. I misinterpret questions quite often when I haven't had my coffee :smiley:

    Kevin

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    Quick note to say that I've committed a fix for this issue. It will be in Select 2.1 which will drop shortly :)

    Allan

Sign In or Register to comment.