Here is a link that shows the issue: JS Bin - Collaborative JavaScript Debugging
When you right click A nothing happens, right click A a second time and the menu appears. OR right click A and then right click B and the menu appears with A's content. I'm simply trying to get the context menu to appear the first time and be specific to the selected row. You right click A you get A's context menu, you right click B you get B's context menu. And always on the first click.
Hello, I'm trying to make the dijit menu's menuitems custom to the item selected in a dgrid row.
Right now the menuitems aren't refreshing when the row changes.
For example if the first row I click on is "C" I get:
First, C1, C2, Last - correct!
If I then right click on row B I get the same thing as above for C.
BUT!, If I then click back onto row C I get:
First, B, Last - incorrect - This is what should have been displayed on the B row click just above.
If I then re-click on row C the menu items are correct. Or if I were to right click twice on any row the second menu items list is correct.
I'm trying to customize the menu items to the row being selected. How can I "refresh", "clear", "reset" whatever so that the menuitems will be specific to the row being selected?
Also, I'm having a problem where I have to right click twice in order to display the context menu. I think it has something to do with my "targetNodeIds" - var pmenu = new Menu({ targetNodeIds: [thisRoot.grid.domNode] });
"thisRoot" is the "window.this", the dgrid scope this.
this.grid.on('.dgrid-row:contextmenu', function (evt) {
evt.preventDefault();
if (selectedRow != null && selectedRow.XObject1 != null) {
var pmenu = new Menu({ targetNodeIds: [thisRoot.grid.domNode] });
pmenu.addChild(new MenuItem({
label: "AlwaysFirstItemInTheList",
iconClass: "FIRST",
onClick: function () { contextFunc(this.id, selectedRow); }
}));
switch (selectedRow.XObject1.XTypeTable) {
case "A":
break;
case "B":
pmenu.addChild(new MenuItem({
label: "B",
iconClass: "B",
onClick: function () { contextFunc(this.id, selectedRow); }
}));
break;
case "C":
pmenu.addChild(new MenuItem({
label: "C1",
iconClass: "C",
onClick: function () { contextFunc(this.id, selectedRow); }
}));
pmenu.addChild(new MenuItem({
label: "C2",
iconClass: "C",
onClick: function () { contextFunc(this.id, selectedRow); }
}));
break;
}
pmenu.addChild(new MenuItem({
label: "AlwaysLastItemInTheList",
onClick: function () { contextFunc(this.id, selectedRow); }
}));
pmenu.startup();