Setting a Context Menu

There are several functions available on the One.TLV class and you can see a complete list in the JS documentation. Here we are going to outline how to add a cell context menu to the TLV.

The function to set a cell context menu is setContextMenus(contextCellType, contextMenuCfg). It takes in an array of config objects and sets the context menu for a given cell context type. Below are examples for each cell context type along with the result in the UI:

  • TLVContextMenuType.BUCKET: Buckets are specified using an object in which the keys are data measure names and their values are the array of menu items:

    tlv.setContextMenus(One.TLVContextMenuType.BUCKET, {
        DMA: [{
            xtype: 'menuitem'
            ,text: 'Test bucket item'
            ,handler: Ext.emptyFn
            ,scope: this
        }]
    });

  • TLVContextMenuType.BUCKET_HEADER: Bucket headers are specified using an object in which the keys are bucket indexes and their values are the array of menu items:

    tlv.setContextMenus(One.TLVContextMenuType.BUCKET_HEADER, {
        0: [{
            xtype: 'menuitem'
            ,text: 'Test bucket header item'
            ,handler: Ext.emptyFn
            ,scope: this
        }]
    });




  • TLVContextMenuType.DM_HEADER: Data measure headers are specified just like buckets: using an object in which the keys are data measure names and their values are the array of menu items:

    tlv.setContextMenus(One.TLVContextMenuType.DM_HEADER, {
        DMA: [{
            xtype: 'menuitem'
            ,text: 'Test DM header item'
            ,handler: Ext.emptyFn
            ,scope: this
        }]
    });