We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Right click is selecting rows when Context Menu Items is used

We've set some items for the context menu, but since then, the right click (to open the context menu) is actually selecting the rows and that's not an expected behavior.
For example if I right-click three lines, the three lines are remaining selected.

5 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team March 11, 2019 11:23 AM UTC

Hi Davi, 

Greetings from Syncfusion. 

By default, we have select the rows when we do right click on the row. Because we have shown the default features (Editing, Deleting, Export) of Grid in those context menu. But you need not to select the rows when we do right click on those rows. So, we need some more clarification on your requirement and please provide the following details for better assistance. 

  1. Share an exact requirement on not to select the rows while we click for context menu in Grid.
  2. If you face any issue while do right click with selecting those rows ?
  3. Share a pictorial representation of your requirement.
  4. Share some more details on your requirement with context menu in Grid ?

Regards, 
Thavasianand S. 



DD Davi Daniel Siepmann March 11, 2019 12:47 PM UTC

Good morning you all, thanks for the prompt return.

Share an exact requirement on not to select the rows while we click for context menu in Grid.
Well, let's say you've selected 3 rows to do a bulk action, and then you realize you want to use the "Context Menu" option to do something else. Then in this case, you'll end up with four rows selected instead of the first 3 ones. If you do the bulk action without realizing the Widget actually selected one more for you, you'll end up messing up your stuff.

If you face any issue while do right click with selecting those rows ?
The widget "goes crazy" when you use right click and then you decide clicking over the other rows, even with the "checkboxOnly" set to true. It selects another row, not the one you clicked (and remember, "checkboxOnly" is set to true, so it shouldn't even select any row)

Share a pictorial representation of your requirement
I think the first two answers represents a pictorial action, but the next answer can make it even clearer ;)

Share some more details on your requirement with context menu in Grid ?
We have more then one view for the display of our items, so we've decided to create a dialog for the edition of the records, a dialog we can call from anywhere. So we use the context menu to open this edition dialog. In case the user opens the dialog and decides just to close it, and lets say it does it three items, it'd remain with three "undesired" selected rows, instead of, well, none, as he dit not select anything.

Hope it's clearer. Thank you guys.


PS Pavithra Subramaniyam Syncfusion Team March 12, 2019 06:27 AM UTC

Hi Davi, 
 
We have analyzed your requirement. To cancel selecting the row during context-menu open we suggest you to bind the “mousedown” event to Grid. And based on the clicked mouse button, we will be cancelling the selection in the “rowSelecting” event of Grid. Please refer the code example below, 
 
    var flag = false; 
    var grid = new ej.grids.Grid({ 
        ... 
        rowSelecting:function(args){ 
            if(flag == true){ 
              args.cancel = true;     //cancel the selection during opening context menu by right click 
              flag = false; 
            } 
        }, 
        ... 
    }); 
    grid.appendTo('#Grid'); 
 
    document.getElementById("Grid").addEventListener('mousedown',function(args){ 
      if(args.which == 3){         //check for the right click mouse button 
        flag = true; 
      } 
    }) 
 
 
 
Please get back to us if you need further assistance. 
 
Regards, 
Pavithra S. 



DD Davi Daniel Siepmann March 12, 2019 03:00 PM UTC

The proposed solution did the job.

Thank you for your prompt support!


TS Thavasianand Sankaranarayanan Syncfusion Team March 13, 2019 04:03 AM UTC

Hi Davi, 
 
We are happy that the problem has been solved. 
 
Please get back to us if you need any further assistance.  
                          
Regards, 
Thavasianand S.

Loader.
Up arrow icon