Export (0) Print
Expand All

AxToolbar [AX 2012]

Updated: November 17, 2011

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

The AxToolbar component provides access to the actions that can be performed for the items in a page. The AxToolbar component has the same function as the Toolbar Web Part. Consider using an AxToolbar component in a User Control when you do not want to rely on having a Toolbar web part on the page where the User Control will be used.

The AxToolbar component has the following properties:

Accessibility

Property

Description

AccessKey

Not used for Enterprise Portal.

TabIndex

The tab order of the control.

Appearance

Property

Description

BackColor

This property is inherited from the base control. It is not specific to Enterprise Portal.

BorderColor

This property is inherited from the base control. It is not specific to Enterprise Portal.

BorderStyle

This property is inherited from the base control. It is not specific to Enterprise Portal.

BorderWidth

This property is inherited from the base control. It is not specific to Enterprise Portal.

CssClass

This property is inherited from the base control. It is not specific to Enterprise Portal.

Font

This property is inherited from the base control. It is not specific to Enterprise Portal.

ForeColor

This property is inherited from the base control. It is not specific to Enterprise Portal.

Behavior

Property

Description

Enabled

Specifies whether the toolbar is enabled.

EnableTheming

Indicates whether the control can be themed.

EnableViewState

Specifies whether the control automatically saves its state for use in round-trips.

SkinID

The SkinId of the control skin that provides the skin of the control

ToolTip

Not used for Enterprise Portal.

Visible

Indicates whether the control is visible and rendered.

Data

Property

Description

Expressions

The expressions that are bound to properties of the control.

DataMember

The table or view from the data set that is being used for the toolbar.

DataSourceID

Specifies the AxDataSource component that will be used by the toolbar to access data.

Layout

Property

Description

Height

The height of the control.

Width

The width of the control.

Microsoft Dynamics AX

Property

Description

Menu Item Help

Specifies whether the help text is displayed for each menu item.

Web Menu Name

Specifies the Web Menu item in the AOT that defines the items displayed in the toolbar.

Misc

Property

Description

ID

The programmatic name of the control

CausesValidation

Specifies whether the controls in the validation group specified by the ValidationGroup property will be validated when a toolbar item is clicked.

ValidationGroup

The name of the validation group for which the validation controls will be validated when a toolbar item is clicked. Each validation control has a ValidationGroup property that specifies which validation group it is part of.

The AxToolbar component has the events listed in the following table.

Event

Description

ActionMenuItemClicked

Occurs after an item in the toolbar menu has been clicked and the action has been performed.

ActionMenuItemClicking

Occurs after an item in the toolbar menu has been clicked, but before the action has been performed.

DataBinding

Occurs when the server control binds to a data source.

DataBound

Occurs after the server control binds to a data source.

Disposed

Occurs when a server control is released from memory, which is the last stage of the server control lifecycle when an ASP.NET page is requested.

Init

Occurs when the server control is initialized, which is the first step in its lifecycle.

Load

Occurs when the server control is loaded into the System.Web.UI.Page object.

PreRender

Occurs after the System.Web.UI.Control object is loaded by prior to rendering.

SetMenuItemProperties

Occurs before the menu items in the toolbar are displayed, allowing the properties to be set.

Unload

Occurs when the server control is unloaded from memory.

In most cases, you define the content displayed by a toolbar by using Web Menu and Web Menu Item resources in the AOT. If you need the toolbar content to be more dynamic, you can define the toolbar content with code you add to the User Control that displays the toolbar. You do this by implementing a method that returns an IWebMenuGenerator object for the User Control. This method defines the contents of the toolbar.

The following using statements reference the namespaces that are required to define toolbar content with code.

using Microsoft.Dynamics.Framework.Portal.UI.WebControls;

using Microsoft.Dynamics.AX.Framework.Services.Client;

The following example is the GenerateToolbar() private method for a User Control. It defines the content for an AxToolbar component that is also part of the User Control. The toolbar contains a top-level item and a menu. The menu contains an item and a submenu with two additional items. After the contents of the toolbar have been defined, the completed structure is returned from the method.

// This is a private method that creates the content of a web menu
// that is used for an AxToolbar component.
private IWebMenuGenerator<WebMenuGeneratorEventArgs> GenerateToolbar()
{
    WebMenuItemMetadataHierarchicalContainer toolbar;
    WebMenuItemMetadataHierarchicalContainer menu;
    WebMenuItemMetadataHierarchicalContainer subMenu;
    URLWebMenuItemMetadata workOrderDetails;
    URLWebMenuItemMetadata roomDetails;
    URLWebMenuItemMetadata roomAdd;
    URLWebMenuItemMetadata MicrosoftLink;

    // Create the container that holds the toolbar menu items.
    toolbar = new WebMenuItemMetadataHierarchicalContainer("Toolbar");

    // Add a top-level item to the toolbar.
    MicrosoftLink = new URLWebMenuItemMetadata("Microsoft", "Microsoft", "Link to Microsoft.com", "http://www.microsoft.com");
    toolbar.AddWebMenuItem(MicrosoftLink);

    // Create the container that will hold the menu.
    menu = new WebMenuItemMetadataHierarchicalContainer("Facility", "Facility", "");

    // Define a menu item to add to the menu. This menu item uses an existing
    // web menu item that is defined in the AOT.
    workOrderDetails = new URLWebMenuItemMetadata(MetadataCache.GetURLWebMenuItemMetadata("WorkOrderDetails"));
    menu.AddWebMenuItem(workOrderDetails);

    // Create the container that will act as a submenu.
    subMenu = new WebMenuItemMetadataHierarchicalContainer("Rooms", "Rooms", "Actions for rooms");

    // Define two menu items that will appear in the submenu.
    roomDetails = new URLWebMenuItemMetadata(MetadataCache.GetURLWebMenuItemMetadata("RoomDetails"));
    roomAdd = new URLWebMenuItemMetadata(MetadataCache.GetURLWebMenuItemMetadata("RoomAdd"));

    // Add these menu items to the submenu.
    subMenu.AddWebMenuItem(roomDetails);
    subMenu.AddWebMenuItem(roomAdd);

    // Add the submenu to the menu.
    menu.AddSubMenu(subMenu);

    // Add the menu to the main toolbar.
    toolbar.AddSubMenu(menu);

    // Return the completed menu structure to use for the toolbar.
    return new WebMenuItemMetadataHierarchicalContainerGenerator(toolbar);
}

The contents of the AxToolbar component should be loaded when the page containing the User Control is loaded. In the Page_Load() method for the User Control, the WebMenuGeneratorConstructor for the AxToolbar component is used to create the content. Notice how the toolbar structure returned from the private method in the previous example is used by the constructor of the toolbar.

protected void Page_Load(object sender, EventArgs e)
{
    // Load the contents of the AxToolbar component.
    this.AxToolBar1.WebMenuGeneratorConstructor = this.GenerateToolbar;
}

Community Additions

ADD
Show:
© 2014 Microsoft