All docs
V20.2
20.2
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Add a Simple Action using an Attribute

  • 2 minutes to read

This lesson explains how to add a Simple Action using an attribute. For this purpose, you will add a new method to the DemoTask class, and decorate it with the ActionAttribute attribute.

NOTE

Before you proceed, take a moment to review the following lessons.

Step-by-Step Instructions

  1. Add the Postpone method to the DemoTask class as shown below.

    using System;
    
    [DefaultClassOptions]
    [ModelDefault("Caption", "Task")]
    public class DemoTask : Task {
        //...
        [Action(ToolTip = "Postpone the task to the next day")]
        public void Postpone() {
            if(DueDate == DateTime.MinValue) {
                DueDate = DateTime.Now;
            }
            DueDate = DueDate + TimeSpan.FromDays(1);
        }
    }
    
  2. Display the "Due Date" column in Task List View. Open the MySolution.Module | ModelDesignedDiffs.xafml file. In the Model Designer:

    1. Go to Views | MySolution.Module.BusinessObjects | DemoTask_ListView | Columns.
    2. Right-click the grid header and invoke the column chooser.
    3. Drag the "Due Date" column to the View and save the ModelDesignedDiffs.xafml file.

    blazor tutorial display column listview

  3. Run the application. Select the Task item in the navigation control.

    Select one or more Task objects in the Task List View. The Postpone Action button appears. Click this button. The DueDate property of the selected objects is modified.

Detailed Explanation

Action Attribute

The Postpone method adds one day to the Task.DueDate property. After you decorate this method with the ActionAttribute attribute, the Postpone button will be displayed in the UI, and the Postpone method will be called when a user clicks this button.

TIP

You can use the Action attribute to implement an action that asks a user to specify parameters in a popup dialog (for example, the number of days to postpone a Task ). Refer to the following topic to see an example: How to: Create an Action Using the Action Attribute.

Next Lesson

Access Editor Settings

See Also