SMART datagrid v.1 > Examples

Back  Forward

Column Popup Menu  Example

If specify the name of the popup menu registered as GridBase.registerPopupMenu in DataColumn.popupMenu property, the registered popup menu will be displayed when click the menu button displayed in the data cell with mouse over. In order to display the column popup menu, you should register the menu as in the code below first. 

If would like to display a separate menu depending on the data row, you can use popupMenuCallback. Please refer to "Currency" column settings. 

Code -1
    grid.registerPopupMenu('menu01', [{
        label: 'menu1',
        callback: menuCallback
    }, {
        label: 'menu2',
    },  ...
    ]);

Please refer to Menu Overview help about how to define the menu. 

Grid - 1
rows

In the grid above, the popup menu has been specified in "Country" and "Interest Rate" columns. First, you should specify DataColumn.button property as "popup". And then, specify the name of the popup menu registered above in popupMenu

A button will be displayed in the data cell of the corresponding column once the popup menu is specified, and it will be specified in buttonVisibility property. "Country" column has been specified through ButtonVisibility.ALWAYS and "Interest Rate" column has been specified through DEFAULT as a default value. 

Please change buttonVisibility of "Interest Rate" column. 

Button Visibility:

If set visible, it will display the button only in Focused Cell

Code -2
    grid.setColumns([{
        ...
    }, {
        "name": "Country",
        "fieldName": "country",
        "button": "popup",
        "popupMenu": "menu01",
        "buttonVisibility": DataLudi.ButtonVisibility.ALWAYS
    }, {
        "name": "Country",
        "fieldName": "country",
        "button": "popup",
        "popupMenu": "menu02"
    },  ...
    ]);

View Source JSP 

See Also
Menu Overview
GridBase.registerPopupMenu
GridBase.unregisterPopupMenu
GridBase.focusedIndex
DataColumn.popupMenu
DataColumn.popupMenuCallback
DataColumn.button
DataColumn.buttonVisibility
Examples
ContextMenu