Get Free Trial
  1. API reference
Connecting to Data Source
Configuring the component
  • Documentation for older versions
  • Table of contents

    Customizing the context menu

    Flexmonster provides a context menu for the grid’s and chart’s elements where you can drill through values, open filters, or change aggregations. This tutorial explains how the context menu can be customized to provide new functionality.

    The context menu can be customized via the customizeContextMenu API call.

    Removing items from the context menu

    customizeContextMenu returns an array of objects, each of which describes a context menu item. Certain items can be removed by deleting the corresponding object from the array. The following example removes all context menu items:

    flexmonster.customizeContextMenu(function(items, data, viewType) {
    	return [];
    });

    Open the example on JSFiddle.

    Adding new items to the context menu

    The following code will add a new item to the flat table context menu:

    flexmonster.customizeContextMenu(function(items, data, viewType) {
    	if (viewType == "flat") 
    		items.push({
    			label: "Switch to charts",
    			handler: function() {
    				flexmonster.showCharts();
    			}
    		});
    	return items;
    });

    Open the example on JSFiddle.

    Check out a full description of the customizeContextMenu parameters.

    What’s next?

    You may be interested in the following articles: