How to distinguish between select vs de-select on user-select event?

How to distinguish between select vs de-select on user-select event?

railsprogrammer94railsprogrammer94 Posts: 3Questions: 1Answers: 0

I'm trying to prevent the capture of select event when the datatable next and previous buttons are used, and so I am trying to use 'user-select' instead of 'select' event. However, 'user-select' event is also capturing de-selects, which I do not want. How can I fix this?

Answers

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    I believe the solution in this thread will allow you to determine if the row was selected or deselected in the user-select event. Not sure how the next and previous buttons are involved. Are you seeing the user-select event fire when using the next and previous buttons?

    Kevin

  • railsprogrammer94railsprogrammer94 Posts: 3Questions: 1Answers: 0

    @kthorngren

    I believe the reason why it fires on next and previous buttons is if there are selected records on that particular page the user navigates to

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    None of the select events are fired when clicking any of the paging buttons. Doesn't matter if the page you are on or the page you are going to has a selected row or not. See this test case:
    http://live.datatables.net/cisawoqo/1/edit

    I added the code I linked to so you can see that working too. Please provide a link to your page or a test case showing the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Are you by chance using the Gyrocode checkbox plugin with server side processing? Paging might fire the select event (not user-select) as this plugin keeps track of selected rows across pages and re-selects them when changing pages.

    Kevin

  • railsprogrammer94railsprogrammer94 Posts: 3Questions: 1Answers: 0

    @kthorngren

    You are correct, I am using the Gyrocode plugin, good catch!

    For now I will solve this problem by setting a global boolean storing when an event is user generated or not, and seperating user generated select and deselect events from the plugin generated ones.

    Thanks for all your help!

Sign In or Register to comment.