Skip to main content
A newer version of this page is available. .
All docs
V22.1

Add a Simple Action using an Attribute

  • 2 minutes to read

This lesson explains how to use methods of a business object to add a Simple Action.

The instructions below show how to add a new method with the ActionAttribute attribute to the DemoTask class.

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:

    namespace MySolution.Module.BusinessObjects
    
    [DefaultClassOptions]
    [ModelDefault("Caption", "Task")]
    public class DemoTask : DevExpress.Persistent.BaseImpl.EF.Task {
        //...
        /*Use this attribute to display the Postpone button in the UI
        and call the Postpone() method when a user clicks this button*/
        [Action(ToolTip = "Postpone the task to the next day")]
        //Shift the task's due date forward by one day
        public void Postpone() {
            if(DueDate == DateTime.MinValue) {
                DueDate = DateTime.Now;
            }
            DueDate = DueDate + TimeSpan.FromDays(1);
        }
    }
    

    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 for an example: How to: Create an Action Using the Action Attribute.

  2. Display the Due Date column in the Task List View. Open the MySolution.Module | ModelDesignedDiffs.xafml file. In the Model Editor, do the following:

    • Go to Views | MySolution.Module.BusinessObjects | DemoTask | DemoTask_ListView | Columns.
    • Right-click the grid header and click the Column Chooser item.
    • 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 tasks in the Task List View. The Postpone Action button appears. Click this button. The due date of the selected tasks shifts forward by one day.

    Blazor tutorial attribute action postpone

Next Lesson

Access Editor Settings

See Also