Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
385
How can I implement oncontextmenu via the csom?
posted

I want to enable users to right click a cell (or row) and see a popup menu. I played with the activation event but it doesn't get fired if the user right clicked. It only gets fired when the user left clicks.

Parents
  • 28464
    posted

    Hello,

    Yes, I also could not find right-click / context menu events in the Activation / Selection behaviours, but this can easily be addressed by using some javascript CSOM. In this particular code snippet, I am assigning a client-side event for clicking on the first cells of the second row of the grid and checking for right-click. You can use this code to show custom context menu 

                var grid = $find("<%= WebDataGrid1.ClientID %>");
                var gridRow = grid.get_rows().get_row(2);
                gridRow.get_cell(0).get_element().onmouseup = function(e) {
                    if (!e)
                        e = window.event;

                    if (e.button == 2) {
                        alert("Right Click");
                    }
                }

     Showing custom popup menu (using UltraWebMenu) is shown in this example:


Reply Children
No Data