Xbasic

a5wcb_convertFriendlyMenuToExpandingMenuJSONData Function

Syntax

C json = a5wcb_convertFriendlyMenuToExpandingMenuJSONData(C menu )

Arguments

menuCharacter

The friendly menu definition (see description below)

Returns

jsonCharacter

Returns the 'friendly' menu formatted as JSON that can be used to populate an Expanding Menu control.

Description

Generates the JSON to populate an Expanding Menu control from a 'friendly' menu definition.

Discussion

The a5wcb_convertFriendlyMenuToExpandingMenuJSONData() function can be used to generate the JSON needed to populate an Expanding Menu control from a menu definition that uses a CRLF list of menu entries, with tab indentation to indicate menu hierarchy.

The menu definition allows you to assign a optional server-side show/hide expression and/or a set of security groups to any menu branch or leaf item. The JSON that is generated will honor the server-side show/hide expressions and security groups. For example, if a menu branch should only be available to someone who is a member of the Administrators group, the generated JSON will not include that branch if the currently logged in user is not in the Administrators group.

The example below shows a "friendly" menu definition:

A 'friendly' menu definition
Alpha
	Alpha1
	Alpha2
		Alpha21
		Alpha22
Beta
	Beta1
Gamma
	Gamma1

Each item in the menu can be followed by an optional JSON definition. This JSON definition can have these properties (all of which are optional)

icon

The icon to show to the left of menu item in the Expanding Menu.

onclick

The Javascript code to execute when the menu item is clicked.

serverSideShowHideExpn

The server-side expression. If this expression is false, the menu item is not shown.

securityGroups

A comma delimited list of security groups. If the user is not in one of the security groups, the menu item is not shown.

The above "friendly" menu definition, using the optional JSON settings string for some of the menu items:

Alpha{serverSideShowHideExpn: 'session.var1 = "alpha"'}
	Alpha1
	Alpha2
		Alpha21{securityGroups: 'Administrator,Sales'}
		Alpha22
Beta
	Beta1
Gamma{icon: 'svgIcon=#alpha-icon-bandAidCrossed:icon,24'}
	Gamma1