Demo - Context Menus

by Manish Gupta

HTML

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.filter.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.sheet.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.chart.min.js"></script>
<div class="container">
  <h3>
    FlexSheet with ContextMenu
  </h3>
  <div id="theSheet" class="has-ctx-menu"></div>
</div>

CSS

.has-ctx-menu{
 height:500px; 
  
}

JavaScript

onload = function() {

  
  
  // create FlexChart, FlexGrid, and FlexSheet
 
  var theSheet = new wijmo.grid.sheet.FlexSheet('#theSheet');
theSheet.addBoundSheet('Sheet0',getData());
theSheet.addUnboundSheet('Sheet1',5,5);
theSheet.hostElement.addEventListener('contextmenu',function(e){    
	e.preventDefault();	
},true)

//hide contextmenu in iPad safari/chrome
theSheet.hostElement.addEventListener("touchstart",function(e){
                var userAgent = window.navigator.userAgent;
                if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
                    setTimeout(function(){
                        theSheet._contextMenu.hide();                    
                    },501);
                }                
            },true);
  // create some random data
  function getData() {
    var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
      data = [];
    for (var i = 0; i < countries.length; i++) {
      data.push({
        id: i,
        country: countries[i % countries.length],
        sales: Math.random() * 100000,
        expenses: Math.random() * 50000
      });
    }
    return data;
  }
}