Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Global events

Menu item: Modify

Scroll Prev Next More

Description

The ModifyMenuItem event is executed for each Menu item before the page is displayed in the browser. Use this event to modify or hide menu items.

Syntax

ModifyMenuItem(menuItem)

Arguments

menuItem

a menu item object.

Return value

True: a menu item is shown.

 

False: a menu item is hidden.

Applies to pages

All pages with the Menu items.

Methods

getLinkType()

gets the link type.

Note: The link types are: Internal (link to a page generated by ASPRunnerPro, e.g. List, Print etc.), External (link to any external web page), None (if menu item is not a link: for example, a group or separator).

 

getUrl()

gets the URL of an external link.

setUrl(url)

sets the URL of the link and makes it external.

getParams()

gets the parameters of an internal link.

setParams(params)

sets the parameters of an internal link. These parameters may be also set on the Choose page screen using the '...' button next to the List page.

Note: The parameters are a part of the link. E.g., if the parameters are foo=bar&bar=foo, the link is ...list.asp?foo=bar&bar=foo.

 

setTitle(title)

sets the title of the link.

getTitle()

gets the title of the link.

getTable()

gets the table name that an internal link points to.

setTable(table)

sets the table name.

getPageType()

gets the page type (List, Add, etc.).

setPageType(pType)

sets the page type (List, Add, Search, Print, Report, Chart).

Examples

Adding parameters to a menu item

if menuItem.getLinkType() = "External" then
   menuItem.setUrl("https://localhost/mn1/carsmodels_list.asp")
elseif menuItem.getLinkType() = "Internal" then
   menuItem.setParams("id=30")
  if menuItem.getTable() = "carsmake" then
       menuItem.setTable("carsmodels")
  end if
else
   ModifyMenuItem = false
  exit function
end if
ModifyMenuItem = true

Hide some menu items based on the group of the authorized user

If the menu item is a link to an internal application page, you can assign the table permissions.

 

However, if the menu item is an external link, you need to set the permissions directly in the Menu Item: Modify event.

 

if Session("GroupID")<>"manager" then
   title = menuItem.getTitle()
  if title="Yahoo Finance" then
       ModifyMenuItem = false
      exit function
   end if
end if
ModifyMenuItem = true

Display a record counter next to each menu item

The code checks if the menu item is an internal table or view and adds the number of records to the menu item title.

 

if menuItem.getLinkType() = "Internal" and menuItem.getPageType() <> "WebReports" then
   Set settings = (CreateClass("ProjectSettings",1,menuItem.getTable(),Empty,Empty,Empty,Empty,Empty,Empty))
   table = settings.getOriginalTableName()
   set rs=CustomQuery("select count(*) as c from " & AddTableWrappers(table))
   menuItem.setTitle_p1(menuItem.getTitle() & " (" & rs("c") & ")")
end if
ModifyMenuItem = true

Hide some menu items in the Mobile mode

if menuItem.getTable() = "Cars" and MobileDetected() then
   ModifyMenuItem = false
  exit function
end if
ModifyMenuItem = true

Recommended predefined actions and sample events:

Check to see if a specific record exists

See also:

Choose pages screen

Menu builder

Working with page elements

RunnerPage class: hideItem()

Datasource tables

Session keys

Save user data in session variables

DAL method: CustomQuery

Database API: Query()

Javascript API: toggleItem()

Events. Redirect to another page