166
Views
4
Comments
Solved
[OutSystems Data Grid] How to open Context Menu of Data grid on click of Icon?
outsystems-data-grid
Reactive icon
Forge asset by OutSystems
Application Type
Reactive

Hello all, 

I need some help regarding Datagrid. If anyone has worked on it or know any working solution, please guide. 

Following is the scenario: In Datagrid we have a default menu (ContextMenu) which opens when right clicked. But we want the same menu Opens on left click of an icon. Icon is present in Action column  Following is the screenshot for reference. 

 

2019-09-30 07-35-56
Aurelio Junior
Solution

Hello,

Maybe there's an easier way, but the only way I could find to do this is via JavaScript. This is how I set up the ActionColumn to show the icon:

And this is my client action and JavaScript:

The JavaScript code:

var element = document.getElementById($parameters.GridWidgetId).querySelector('.datagrid-runtime');
var button = document.querySelector('.wj-state-selected .icon');
var evt = new MouseEvent("contextmenu", {
    clientX: button.getBoundingClientRect().x,
    clientY: button.getBoundingClientRect().y
});
element.dispatchEvent(evt);

2022-12-05 07-28-20
Nihil Gujar

Hello

Appreciate your help.

Can you please suggest how can I disable Right Click inside Grid.


Thanks 

Nihil  

2022-12-05 07-28-20
Nihil Gujar

hello

Actually this Java script is only working on first row icon.

2019-09-30 07-35-56
Aurelio Junior

Hi,

It should work for all rows of the DataGrid. I've tested it myself. Here's a module with my implementation for reference.

DataGridSample.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.