Click or drag to resize

MapperCommand Class

Describes a command added to a page by a Mapper extension.
Inheritance Hierarchy
SystemObject
  NetQuarry.DataMapperCommand

Namespace:  NetQuarry.Data
Assembly:  EAP.Core (in EAP.Core.dll) Version: 2.0.0.0 (4.6.8.0)
Syntax
public class MapperCommand : ICloneable

The MapperCommand type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyAction
Gets or sets the command's action.
Public propertyAttributes
Command presentation attributes.
Public propertyCaption
Gets or sets the command's caption. The caption is the text displayed to the user on the More menu and shown under the image if the command is located on the toolbar and toolbar captions are displayed.
Public propertyCommand
The command name used programmatically to invoke specific behaviour. By default, and in most cases, Command is the same as ID. However, Command can be set programmatically to be different from ID In the case where a MapperCommands collection needs to contain multiple MapperCommand objects with the same command, for example where the same command is required with two different MapperCommandLocation values.
Public propertyConfirmMessage
Specifies the confirmation message to display before posting the command back to the extension
Public propertyCssClass
Gest/sets the CSS class to be applied to the command toolbar button.
Public propertyExtraHtml
Gets/sets additional HTML to be appended to the command item. This HTML will not be escaped and should be set with care.
Public propertyID
Gets or sets the command's ID.
Public propertyImage32URL
Gets or sets the command's 32x32 image path.
Public propertyImageURL
Gets or sets the commands 16x16 image path.
Public propertyLocation
Gets or sets the command's location. (Toolbar or MoreMenu)
Public propertyNavTarget
Gets or Sets the NavTarget this command is based on.
Public propertyParentCommand
Gets/sets the ID (name) of the parent command for this item. A parent command constitutes a submenu item and all items having the same parent will be grouped under that parent. If no other command is found having the specified ID, then a parent command will be added automatically.
Public propertyRowKeys
The set of RowKeys for which this command applies. Applies only to RowMenu commands. When the MapperCommand event is fired, the selected key will be provided in RowKey.
Public propertyScript
Gets or sets the command's javascript.
Public propertySourceName
Gets/set the name of the source for this command.
Public propertyStatusText
Gets/sets the text used for the client-side progress indicator. If no text is set then no progress indicator will be presented.
Public propertyTooltip
Gets or sets the commands tooltip.
Public propertyToolTip
Gets or sets the command's tooltip.
Public propertyURL
Gets or sets the command's URL. You may set the URL if your command is a simple navigation command to another page or URL.
Public propertyWindowOptions
Gets or sets the command's window options. Window options are passed to window.open for commands that are javascript based. This parameter is a list of items separated by commas and corresponds to the "Features" parameter in the DHTML window.open() method. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following features are supported.
Top
Methods
  NameDescription
Public methodClone
Clone the command.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a String that represents the current Object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodEqualValue
Determines if the object value is equal to another object. If the two objects are null, then this returns true. There is special handling for guid comparisons (since a guid could be a string formatted in up to 3 different ways). If the special guid handling is not performed, then the object.Equals method is used.
(Defined by EAPUtil.)
Top
Examples
The following override of MapperExtensionKernel.MapperBeforeLayout demonstrates adding a command to a mapper to support exporting to excel. Note that a custom property (CommandLocation) is used to allow for per-mapper specified override to the location of the command.
public override void MapperBeforeLayout(IMapper sender, EAPEventArgs e)
{
    MapperCommand cmd = new MapperCommand();
    MapperCommandLocation location = MapperCommandLocation.MoreMenu;

    cmd.Caption = "Export to Excel";

    int nLocation = this.Properties.GetIntValue("CommandLocation", (int)MapperCommandLocation.MoreMenu);

    if (((MapperCommandLocation)nLocation) == MapperCommandLocation.Toolbar)
    {
        location = MapperCommandLocation.Toolbar;
    }

    cmd.Location = location;
    cmd.ToolTip = "Export the current data to Microsoft Excel";
    cmd.WindowOptions = EAPUtil.WindowOpenFeatures(WindowOpenOptions.Standard, 0, 0);

    if ((location == MapperCommandLocation.Toolbar) &&
        sender.Application.Properties.GetBoolValue("ToolbarLargeIcons"))
    {
        cmd.ImageURL = "images/excel32.bmp";
    }
    else
    {
        cmd.ImageURL = "images/excel.bmp";
    }

    cmd.Atributes |= UICommandAttrs.ExistingOnly;

    sender.Commands.Add("excelexport", cmd);
}
Examples
The following FieldButtonClick handler demonstrates how to return an error from an event and execute a SQL statement to update a table.
public override void FieldButtonClick(IField sender, EAPEventArgs e)
{
    if (sender.Key == "btn_enable")
    {
        IField fldID = sender.Fields["dealer_id"];
        IField fldDealershipID = sender.Fields["dealership_id"];
        string dealerID = EAPUtil.ToString(fldID.Value);
        string sql = string.Format("UPDATE dealer SET status_id = 1 WHERE dealer_id = '{0}'", dealerID);

        if (0 == EAPUtil.ToString(fldDealershipID.Value).Length)
        {
            e.Error("You must select a dealership for this dealer before they can be enabled.");
            return;
        }                
        sender.Database.Execute(sql);
    }
}
See Also