When you enhance the context menu with customer-specific entries (with the JavaScript function 'sapbi_addToMenu'), you must define a JavaScript function that is executed when a customer-specific entry is selected. This function is responsible for processing the command.
The function must support the following interface:
JavaScript Function | JavaScript Function for Processing the Command |
---|---|
Parameter | Description |
parameter
|
Free parameter The parameter makes it possible to process more than one menu entry with one function. See Examples. |
cell_type
|
Context of cell ' ' = No special 'CHARACTERISTIC' = Characteristic 'CHARACTERISTIC_VALUE' = Characteristic value 'STRUCTURE' = Structure 'STRUCTURE_VALUE' = Structure component value 'DATA' = Data cell 'EXCEPTIONS' = Web Item List of Exceptions 'CONDITIONS' = Web Item List of Conditions 'DOCUMENT_LIST' = Web Item List of Documents |
Filter
|
Context of cell Different values are suitable, depending on the value of 'cell_type': 'CHARACTERISTIC', 'CHARACTERISTIC_VALUE', 'STRUCTURE', 'STRUCTURE_VALUE': Iobjnm 'EXCEPTIONS': Exception ID 'CONDITIONS': Condition ID 'DOCUMENT_LIST': Document ID See "Example" below. |
parameter1
|
Exact definition of the context of the cell cell_type = 'CHARACTERISTIC_VALUE': Key for characteristic value cell_type = 'STRUCTURE_VALUE': STRUCTURE_MEMBER_ID_1 |
parameter2
|
Exact definition of the context of the cell cell_type = 'CHARACTERISTIC_VALUE': Node type for a hierarchy node cell_type = 'STRUCTURE_VALUE': STRUCTURE_MEMBER_ID_2 |
item
|
Name of the Web item on which the menu is called |
dataprovider |
Name of the data provider for which the menu is called up |
x
|
Cell is on data column x This parameter is needed especially for the report/report interface. |
Y
|
Cell is on data row y This parameter is needed especially for the report/report interface. |
You can use the JavaScript-API to execute commands. More information: JavaScript API for Executing Commands
This example enhances the context menu with the entries with which you can activate or deactivate the alternate rows property. Two context menu entries are added. The menu handler (in this case the JavaScript function alternate_context_menu) converts the command.
<bi:bisp xmlns="http://www.w3.org/TR/REC-html40" xmlns:bi="http://xml.sap.com/2005/01/bi/wad/bisp" xmlns:jsp="http://java.sun.com/JSP/Page" >
<html>
<head>
<title >BEx Web Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<bi:QUERY_VIEW_DATA_PROVIDER name="DP_1" >
<bi:INITIAL_STATE type="CHOICE" value="QUERY" >
<bi:QUERY value="0D_DX_M01_Q0006" />
</bi:INITIAL_STATE>
</bi:QUERY_VIEW_DATA_PROVIDER>
<bi:TEMPLATE_PARAMETERS name="TEMPLATE_PARAMETERS" />
<p >
<bi:ANALYSIS_ITEM name="ANALYSIS_ITEM_1" designwidth="400" designheight="200" >
<bi:DATA_PROVIDER_REF value="DP_1" />
</bi:ANALYSIS_ITEM>
</p>
<p >
<bi:SCRIPT_ITEM name="SCRIPT_ITEM_1" designwidth="300" designheight="70" >
<bi:SCRIPT value="biLargeData:U83SWLZ98BKCPBMOXEYJDNX54" />
</bi:SCRIPT_ITEM>
</p>
<!-- insert data providers, items and other template content here -->
</body>
</html>
</bi:bisp>
The contents of the Script parameter are:
function alternate_context_menu(parameter, cellType, filter, parameter1, parameter2, item, dataProvider, x, y){
var commandSET_ITEM_PARAMETERS_1 = new sapbi_Command( "SET_ITEM_PARAMETERS" );
var paramITEM_TYPE = new sapbi_Parameter( "ITEM_TYPE", "ANALYSIS_ITEM");
commandSET_ITEM_PARAMETERS_1.addParameter( paramITEM_TYPE );
var paramINIT_PARAMETERS = new sapbi_Parameter( "INIT_PARAMETERS" );
var paramListINIT_PARAMETERS = new sapbi_ParameterList();
commandSET_ITEM_PARAMETERS_1.addParameter( paramINIT_PARAMETERS );
var paramALTERNATE_STYLES = new sapbi_Parameter( "ALTERNATE_STYLES",parameter );
paramListINIT_PARAMETERS.addParameter( paramALTERNATE_STYLES );
paramINIT_PARAMETERS.setChildList( paramListINIT_PARAMETERS );
var paramTARGET_ITEM_REF = new sapbi_Parameter( "TARGET_ITEM_REF", item);
commandSET_ITEM_PARAMETERS_1.addParameter( paramTARGET_ITEM_REF );
return sapbi_page.sendCommand( commandSET_ITEM_PARAMETERS_1 );
}
/* Add Contextmenu entries */
sapbi_addToMenu("Alternate Styles on", "alternate_context_menu", "X", "", "", "top", "", "");
sapbi_addToMenu("Alternate Styles off", "alternate_context_menu", "", "", "", "top", "", "")