The following is a programmatic (I don't use declarative)
solution mockup you'll have to complete and adapt to your context
:
grid.on(".dgrid-row:mousedown, mouseDownCallback);
mouseDownCallback: function(evt){
var row = grid.row(evt);
if (mouse.isRight(evt)){
//here build your context menu depending on the
content of row, for example the following will show a context menu
with one item which when clicked will popup an alert box with the
content of the row's name property value:
var theMenu = new Menu({targetNodeIds: [grid.domNode],
selector: ".dgrid-row"});
theMenu.addChild(new MenuItem({label: row.name,
onClick: function(evt){alert('name: ', row.name)});
}
}
grid is an instantiated dgrid. mouse, Menu, MenuItem are the
corresponding dojo / dijit modules. I am using mousedown event and
/ mouse.isRight() for context menus, as the contextmenu event did
not work at the time and in my context for dgrids
jc
Le 09/05/2017 à 23:10, Rieck, Greg a
écrit :
Hello,
I have been
trying to get a context menu to display based on the data
selected in a row in a dGrid. I want the context menu to have
specific menu items dependant on the grid row. For example if
I were to right click on rows A-C here is what I would expect
to see:
ROW
A >
First, Last
B >
First, B, Last
C >
First, C1, C2, Last
I currently
have the context menu displaying, but not uniquely or
"dynamically" by selected row.
1) How can I
get the context menu items to be dependant on the data in the
selected row?
2) When I
very first right click on a row the context menu displays
right away. But if I then right click on a different row
nothing is displayed. But then if I right click again on the
same row the context menu displays. How can I avoid the double
clicking to get the menu to display?
3) I am using
the declarative method to expose the context menu. However, as
part of this entire issue I need to be able to access the
selected row and the selected context menu item in order to
process the "onclick" of the context menu. I have not seen any
examples of how to setup the context menu event and would
really like to see an example if you can provide one.
Thank You,
Greg
--
Dojo Toolkit:
http://dojotoolkit.org/Tutorials:
http://dojotoolkit.org/documentation/[hidden email]
To unsubscribe, visit:
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest