SMART datagrid v.1 > Examples

[ grids ver.1.3.2]   Back  Forward

DataCell Buttons  Example

If specify DataColumn.button property, you can display a button on the right side of the data cell. Currently, you can specify through CellButton.POPUP or ACTION. 

Grid - 1
rows
1. Popup button

In "Country" column, button has been specified as CellButton.POPUP, and DataColumn.popupMenu has been set as "menu01" menu which has been registered in the grid in advance. You can set the display mode of the menu button through buttonVisibility, and determine whether to display it through buttonDisplayCallback finally. In the example, the button is only displayed in the even numbered rows in "Country" column. 

And, you can also use DataColumn.popupMenuCallback to display different menus in each cell. In the example, it displays different menus in each even and odd numbered rows in "Original Amount" column. 

(Country column) Button Visibility:
(Original Amount column) Button Visibility:

(CURRENT since v 1.3.8

Code -1
    var columns = [{
        name: 'Amount',
        button: "popup",
        popupMenu: "menu01",
        popupMenuCallback: function (index) {
            if (index.rowIndex % 2) {
                return 'menu01'
            } else {
                return 'menu02'
            }
        },
        ...
    ];
2. Action button

CellButton.ACTION button has been set in "Interest Rate" and "Currency" columns. Like the example above, you can specify the button display mode, and set whether to display the button through buttonDisplayCallback

If click the button during run time, GridBase.onCellButtonClicked event will be fired. 

Code -2
    grid.onCellButtonClicked = function (grid, index) {
        alert(index.column.name());
    };

View Source JSP 

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