Hi Kasani007,
It is very tough for me to share working code, as it has lot of other functionality implemented, it will be confusing.
Let me give a try to help you.
1) Here 1st you need to understand the
sequence in which listners are called on grid cell right click, so 1st grip panel CellContextMenu gets called and then menu BeforeShow listner is called.
2) for our dynamic grid we have a context menu which we want to show on grid cell right click, so below tag is used for creating context menu
<ext:Menu ID="tier1SummaryMenu" runat="server">
<Items>
----put your context menu items
</Items>
<Listeners>
<BeforeShow Handler="beforeactivate();"></BeforeShow>
</Listeners>
</ext:Menu>
Here BeforeShow listener is important.
var beforeactivate = function () {
var hdnIsHeadderClicked = #{hdnIsHeadderClicked};
if(hdnIsHeadderClicked.rawValue == "0")
{
hdnIsHeadderClicked.rawValue = ""; //// resetting value to ""
return true;
}
if(hdnIsHeadderClicked.rawValue == "") ///// here we are using this hidden field to for disabling context menu.
{
#{tier1SummaryMenu}.disable();
#{tier2SummaryMenu}.disable();
}
}
NOTE: if you right click on grip panel header, then only BeforeShow listner is called and not the CellContextMenu
3) in CellContextMenu listner im setting hdnIsHeadderClicked hidden field value to "0".
4) So, it works like this, if user clicks on grid cell then CellContextMenu gets called and here we set hidden "hdnIsHeadderClicked " value to "0" and after that BeforeShow listner get fired there we are checking if hidden is "0" then reset its value to "" and return, and in other case if user clicks on header then in this case CellContextMenu will not get fired and directly BeforeShow will be called, so here hdnIsHeadderClicked is "", so it disables the menu.
Hope it may help you, if you need anything else just let me know.
Regards,
Prasoon