## Command Tips

### Adding Custom Commands

You can add custom commands to popup menus. For example, if you want to replace the current Show Detail Dialog with a custom dialog, you could disable the supplied Show Detail popup menu command and replace it with your own command.

Use the following code to disable the default Show Detail popup menu command:

    mi.setCommandsMask(MDCommand.ALL_COMMANDS_MASK & ~MDCommand.SHOW_DETAIL_DATA_COMMAND);

When you write the code for your custom Show Detail command, you might want to get the name of the dataset to display in your dialog. You can get this dataset name from the model-supplied ShowDetailCommand class.

The command class has a getDatasetName method that returns the temporary view name that is created when the command is executed on the server. For further details on using this command programmatically, see ShowDetailCommand class.

### Enabling and Disabling Commands

To enable only navigation commands (including Drilldown, Up, Down, Left, Right, Expand, and Collapse), use the following code:

    mi.setCommandsMask(MDCommand.NAVIGATION_COMMANDS_MASK);

### Using Navigation Commands

You can programmatically direct navigation commands. For example, to programmatically direct the Drilldown command, use the MDCommand class.

The following code can be used to drilldown on the first item in the first row of a table:

    AxisLabelInterface[] labels = mi.getAxis(1).getLabels(0);

    MDCommand command = new MDCommand(MDCommand.DRILLDOWN_COMMAND, (Member)labels[0]);

    command.performAction();