Wijmo 5 flex tree grid - right click feature is available?

Posted by: ramu on 29 April 2019, 7:10 am EST

    • Post Options:
    • Link

    Posted 29 April 2019, 7:10 am EST

    Hi,

    I have used Wijmo 5.20171.282 version.

    I have used flex grid with tree view format. But I want to integrate right click feature on the tree node.

    (i.e.) I have created some links and actions for those links. Once right click on the tree node, these custom links panel are need to display on the screen.

    Please let me know, how to accomplish this feature?

    Thanks,

    Ramu

  • Posted 29 April 2019, 9:48 pm EST

    Hello!

    The easiest way to do this is by adding a handler to the “contextmenu” event, which fires when the user right-clicks an item. For example:

    https://jsfiddle.net/Wijmo5/4j1nvm9u/

    The fiddle handles the “contextmenu” event with this code:

      theGrid.hostElement.addEventListener('contextmenu', function(e) {
      	var ht = theGrid.hitTest(e);
        if (ht.panel == theGrid.cells) {
        	var item = theGrid.rows[ht.row].dataItem;
          alert('you right-clicked ' + item.name);
        	theGrid.select(ht.row, 0);
          e.preventDefault();
        }
      })
    
    

    This shows how to handle click events (mouse down, then up on the same element).

    If you want to perform an action on the mousedown event (before the user releases the button), the code is almost the same:

    https://jsfiddle.net/Wijmo5/1ach9x0L/

      theGrid.hostElement.addEventListener('mousedown', function(e) {
      	if (e.button == 2) { // right button
      		var ht = theGrid.hitTest(e);
        	if (ht.panel == theGrid.cells) {
    	    	var item = theGrid.rows[ht.row].dataItem;
    	      alert('you right-clicked ' + item.name);
    	    	theGrid.select(ht.row, 0);
    	      e.preventDefault();
          }
        }
      })
    
    

    I hope this helps.

  • Posted 9 May 2019, 9:49 am EST

    Thank you so much.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels