3

I am using dojo dgrid for table representation. I have handled a row click event with grid.on('.dgrid-content .dgrid-row:click', function(){ // Open a Dialog}). But the problem I am facing here is: while user is trying to select any text on the row with a hope to copy, the event eventually ends up opening the dialog.

As per my knowledge, HTML5 has the support of ondrag event, but that is not working in my case. What are the other ways to separate these two events and handle accordingly?

Thanks in advance.

  • I think its working as expected as you have registered the grid of keyup event. When do you want the dialog to open? onClik of the cell or row – bajji Nov 03 '17 at 14:27
  • 1
    Might be of some help: https://stackoverflow.com/questions/3731328/on-text-highlight-event Other than this you can also track the interval between mousedown and mouseup events to differentiate between click and selection. – Himanshu Nov 07 '17 at 05:00

2 Answers2

2

You can distinguish select from click in following way inside of your click handler:

clickHandler: function () {
            var collapsed = window.getSelection().isCollapsed;
            if (collapsed) {
                console.log("Clicked");
                //Open dialog
            } else {
                console.log("Selected");
                //Do something else
            }
        }
soeik
  • 905
  • 6
  • 15
0

You should add set allowTextSelection to true inside your grid. This allows the user select text inside the rows.

Make sure you read the documentation on the topic.

Ferry Kranenburg
  • 2,625
  • 1
  • 17
  • 23