Controlling the Context Menu Appearance
There are many situations in which you may want to control the appearance of the context menu.
We will go through some of these scenarios in depth here in this chapter.
Using Different Action Descriptors
In some cases you may have a single action which should be displayed in a certain way in the
context menu, and displayed a different way inline in the row. Consider these property groups:
ActionDescriptor{
name: CDT10;
actType: row;
label: 10% Increase;
dspOrder: 10;
}
ActionDescriptor{
name: WARN;
actType: row;
dspType: link;
imgsrc: /dataengine/images/epoint.gif;
dspOrder: 20;
}
The operation screen for these properties would look like this:
The same gif is used to display the WARN action in the row and in the context menu, and the same
text is used to display the “10% Increase” action in both places. Using the ActionContextMenuDescriptor
property group you can set display properties which apply only to the context menu. When a
ActionContextMenuDescriptor is present for an action, then the ActionDescriptor property group is not
used to render that action in the context menu. With these property groups:
ActionDescriptor{
name: CDT10;
actType: row;
label: +10%;
dspOrder: 10;
}
ActionDescriptor{
name: WARN;
actType: row;
dspType: link;
imgsrc: /dataengine/images/epoint.gif;
dspOrder: 20;
}
ActionContextMenuDescriptor{
name: CDT10;
actType: row;
dspType: text;
label: 10% Increase;
}
ActionContextMenuDescriptor{
name: WARN;
actType: row;
dspType: text;
label: Send credit warning;
}
The screen now looks like this:
The following CSS Properties are used to control the appearance of the context menu:
actionmenu - Applied to both TABLE and DIV elements which comprise the context menu. (The
TABLE is contained in the DIV)
actMI - Applied to each TR in the context menu. There is one TR for each action.
actDefMI - Applied to the TR in the context menu which represents the action which is the default
action for the row.
actMI-hlight - Used for the highlighted TR element, which represents the action within the context
menu over which the mouse is hovering.
actSep - Used for the TR element which acts as a separator between different groups of actions.
hidden - Applied to the TR element for actions which are in the context menu but cannot be run.
To change the look and feel of the context menu you can change/replace the definition of these CSS styles.
The group property in the ActionDescriptor and ActionContextMenuDescriptor property groups can be
used to assign multiple actions to a single group. The context menu will show a separator between
different groups of actions. These property groups:
ActionDescriptor {
name: CDT10;
actTyp: row;
label: 10% Increase;
loc: context menu;
group: credit limit;
dspOrder: 10;
}
ActionDescriptor {
name: CDT50;
actTyp: row;
label: 50% Increase;
loc: context menu;
group: credit limit;
dspOrder: 20;
}
ActionDescriptor {
name: WARN;
actTyp: row;
loc: context menu;
label: Send credit warning;
dspOrder: 30;
}
would result in this context menu:
Notice the actions divided into 3 different groups, the "credit limit" group, the send credit
warning action and the common row actions (Edit, View,Copy).
Different Actions for Different Rows
If you are writing custom code then you can have different actions appear in the context menu depending
on which row the user clicks on.
The actions which may appear in the context menu are determined by the first row of the results. An action
may not appear in the context menu unless it is an action for that first row. However, if an action is not
applicable for a particular row then it is not shown in the context menu for that row. The Row.isActionApplicable
(String, ExecutingContext) method is used to determine whether or not an action is applicable to a particular row.
If this method is overridden to return false for certain rows, then for those rows only the action will not be
displayed in the context menu.
All actions are applicable for this row:
Some actions are not applicable, and therefore are not displayed, for this row:
Notice that the second customer does not have the Credit Limit Increase options in the context menu.