Ignore 'Select' on double click?

Ignore 'Select' on double click?

tekuilatekuila Posts: 24Questions: 5Answers: 0

I use select extension to select rows.

And when doubleclicking, it links to another page.

So when doubleclicking, it selects, unselects and then redirects.

But how to avoid the unselect un doubleclick?

Thanks.

Answers

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

    One option is to use checkbox selection instead of whole row selection as shown in this example:
    https://datatables.net/extensions/select/examples/initialisation/checkbox.html

    Kevin

  • tekuilatekuila Posts: 24Questions: 5Answers: 0

    Thank you but it has to be whole row selection.

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

    You may be interested in the developers response to using double clicks in this thread:
    https://datatables.net/forums/discussion/comment/161983/#Comment_161983

    Its not asking about the same use of double click as you but his answer is relevant.

    Kevin

  • tekuilatekuila Posts: 24Questions: 5Answers: 0
    edited December 2019

    Thanks guys. Found a solution to add this:

    $('#datatable_drafts tr').click(function(e) {
          if(!e.detail || e.detail == 1){
    }}
    

    So the longer code is:

    $('#datatable_drafts tr').click(function(e) {
          if(!e.detail || e.detail == 1){
            $(this).toggleClass('selected');
            var selected = table.rows('.selected').data();
          $(".check-button input").prop('checked', false);
          table.$("tr.selected").each(function(){
            var checkbox = $(this).find('.check-button').find('input');
            checkbox.prop('checked', true);
          });
        })
    

    Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This discussion has been closed.