[CLOSED] grid panel context menu.

  1. #1

    [CLOSED] grid panel context menu.

    Hi,

    i am showing a context menu on grid panel cell click, but want to disable RIGHT CLICK on grid header, please help.

    thanks and regards,
    Prasoon
    Last edited by Daniil; Jun 02, 2015 at 5:46 PM. Reason: [CLOSED]
  2. #2
    Hi Prasoon

    I can suggest something. Set the following Listener on your Menu

                <Listeners>
                    <BeforeShow Fn="beforeactivate" />
                </Listeners>
    and the respective JavaScript code

            var beforeactivate = function (menu) {
                var targetDiv = "";
                targetDiv = menu.contextEvent.e.target.outerHTML;
                if (targetDiv.search("header") != -1)
                    return false;
            }
    This gets the target div where the event occurred. And since the generated HTML for Panel headers contains "header", we can know if the click occurred on the header and therefore prevent the menu from showing up.
  3. #3
    Thanks a lot EnZo,
    In my case i am creating dynamic grid panel, return false is not working for me.
    But some how i achieved it, by using hidden fields and CellContextMenu & BeforeShow listeners.
  4. #4
    hi Prasoon,

    I have aslo same porblem.
    Can You Please Elaborate How can you resolve the problem By giving some piece of code

    Thanking You In Advance
  5. #5
    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
    Last edited by Daniil; Sep 19, 2015 at 2:53 PM.
  6. #6
    May I Know Where is and what is #hdnIsHeadderClicked And Where did you used CellContextMenu
  7. #7
    1) CellContextMenu: Its a ViewConfig listner, ViewConfig is view configuration of grid, you need to add viewconfig tag inside grid panel tag, like below code

                                <ViewConfig>
                                    <Listeners>
                                        <CellContextMenu Fn="preventRightClickon" />
                                    </Listeners>
                                </ViewConfig>

    2) hdnIsHeadderClicked, is an ext hidden field, this used to check whether right click is on header or grid cell.

    3) How to check whether the right click is on header or the cell, you need to read my above explanation once again.

    if you need anything else, just let me know.

    regards,
    Prasoon

Similar Threads

  1. [CLOSED] grid panel context menu items.
    By Prasoon in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 02, 2015, 6:02 AM
  2. [CLOSED] Column index or the header value of a grid panel in context menu.
    By arjunrvasisht in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 07, 2015, 10:34 AM
  3. Replies: 2
    Last Post: Apr 04, 2014, 5:11 AM
  4. [CLOSED] context menu in the tree panel?
    By hdsoso in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 10, 2013, 11:58 AM
  5. [CLOSED] Tab Panel Context Menu
    By skyone in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 12, 2011, 4:56 PM

Tags for this Thread

Posting Permissions