Add a Simple Action using an Attribute 使用特性添加简单按钮
In the previous Add a Simple Action lesson, you learned how to add an Action by implementing the View Controller. There is another approach that may be more convenient when the Action is intended for a certain business class. In this lesson, you will learn how to add a Simple Action using an attribute. For this purpose, a new method will be added to the DemoTask class, and the ActionAttribute attribute will be applied to it.
在前面的"添加简单按钮"课中,您学习了如何通过实现视图控制器来添加操作。当 Action 适用于特定业务类时,还有另一种方法可能更方便。在本课中,您将学习如何使用属性添加简单操作。为此,新方法将添加到 DemoTask 类中,并将 Action属性属性应用于该方法。
Note 注意
Before proceeding, take a moment to review the following lessons.
在继续之前,请花点时间复习以下课程。
- Set a Many-to-Many Relationship (XPO/EF)
- Add a Simple Action
Add the Postpone method to the DemoTask class as shown below.
设置多对多关系 (XPO/EF)
添加简单操作
- 将"推迟"方法添加到演示任务类,如下所示。
[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();
}
}
- The Postpone method sets the Task.DueDate property to the next date, after the date previously specified. Since the ActionAttribute attribute is used, the Postpone button will be displayed in the UI, and the Postpone method will be called when clicking this button.
- "延迟"方法将 Task.DueDate 属性设置到下一个日期,该日期是以前指定的日期之后。由于使用了 ActionAttribute 属性,因此"推迟"按钮将显示在 UI 中,单击此按钮时将调用"推迟"方法。
Run the WinForms or ASP.NET application. Select the Task item in the navigation control. Show the Due Date column using the Column Chooser. To activate the Column Chooser, right-click the Task List View header. The Column Chooser allows end users to show or hide columns at runtime, by dragging a column header to or from the table header.
运行 WinForms 或ASP.NET应用程序。在导航控件中选择"任务"项。使用列选择器显示到期日期列。要激活列选择器,请右键单击"任务列表视图"标头。列选择器允许最终用户在运行时通过将列标题拖动到表标题或从表标题中显示或隐藏列。

- Select one or more Task objects in the Task List View. Find the Postpone toolbar button, which represents the Postpone Action that you have implemented above. Click this button. The DueDate property of the selected objects displayed in the Due Date column will be modified.
在"任务列表"视图中选择一个或多个"任务"对象。查找"推迟"工具栏按钮,该按钮表示您在上面实现的"推迟操作"。单击此按钮。将修改"到期日期"列中显示的选定对象的"过期日期"属性。


Tip 提示
When the browser window shrinks, some Actions become hidden and can be accessed using the "..." button (see IModelActionWeb.AdaptivePriority).
当浏览器窗口收缩时,某些操作将变为隐藏状态,可以使用"...""按钮进行访问(请参阅 IModelActionWeb.自适应优先级)。
Note 注意
You can also use the Action attribute to implement an action that asks an end user to specify parameters in a popup dialog (e.g., the number of days to postpone a Task ). Refer to the How to: Create an Action Using the Action Attribute topic to see an example.
您还可以使用 Action 属性实现一个操作,要求最终用户在弹出对话框中指定参数(例如,推迟任务的天数)。请参阅"如何:使用操作属性创建操作"主题以查看示例。
You can see the code demonstrated here in the MySolution.Module | Business Objects | DemoTask.cs (DemoTask.vb) file of the Main Demo installed with XAF. The MainDemo application is installed in %PUBLIC%\Documents\DevExpress Demos 19.2\Components\eXpressApp Framework\MainDemo by default. The ASP.NET version is available online at http://demos.devexpress.com/XAF/MainDemo/
您可以在 MySolution.模块 |业务对象 |DemoTask.cs (DemoTask.vb) 文件的主演示安装与 XAF.主演示应用程序安装在%PUBLIC%\Documents\DevExpress Demos 19.2\Components\eXpressApp Framework\MainDemo by default. The ASP.NET version is available online at http://demos.devexpress.com/XAF/MainDemo/
.
Add a Simple Action using an Attribute 使用特性添加简单按钮的更多相关文章
- Add a Simple Action添加简单按钮
In this lesson, you will learn how to create a Simple Action. For this purpose, a new View Controlle ...
- Add a Parametrized Action 添加带参数的按钮
In this lesson, you will learn how to add a Parametrized Action. These types of Actions are slightly ...
- How do I add a simple onClick event handler to a canvas element?
How do I add a simple onClick event handler to a canvas element? When you draw to a canvas element, ...
- asp.net core的授权过滤器中获取action上的Attribute
var action = context.ActionDescriptor as ControllerActionDescriptor; var permission = action.MethodI ...
- [LeetCode] Add Bold Tag in String 字符串中增添加粗标签
Given a string s and a list of strings dict, you need to add a closed pair of bold tag <b> and ...
- Android中使用Intent的Action和Data属性实现点击按钮跳转到拨打电话和发送短信
场景 点击拨打电话按钮,跳转到拨打电话页面 点击发送短信按钮,跳转到发送短信页面 注: 博客: https://blog.csdn.net/badao_liumang_qizhi 关注公众号 霸道的程 ...
- Android UI ActionBar功能-Action Bar 左上角的向上或返回按钮
ActionBar在左上角还提供了一个向上或返回的按钮,默认情况下是隐藏的需要在代码中开启: 官方文档:http://wear.techbrood.com/training/basics/action ...
- Simple But Useful Samples About 'grep' Command(简单实用的grep 命令)
Do the following: grep -rnw '/path/to/somewhere/' -e "pattern" -r or -R is recursive, -n i ...
- MyEclispe点击add deploment 无反应的处理,无法添加项目到Tomcat
比如你的工作空间为 E:\workspace-project 找到以下路径: E:\workspace-project\.metadata\.plugins\org.eclipse.core.runt ...
随机推荐
- LeetCode刷题总结-二分查找和贪心法篇
本文介绍LeetCode上有关二分查找和贪心法的算法题,推荐刷题总数为16道.具体考点归纳如下: 一.二分查找 1.数学问题 题号:29. 两数相除,难度中等 题号:668. 乘法表中第k小的数,难度 ...
- Ajax获取网页添加到div中
1:利用DOM获取该 div 的 ID,然后清空该DIV的内容(如果你需要接着里面的内容添加可不要清空):需要注意点是清空最好用“ empty() ”: 2: 把 async设成true ,否则又 ...
- IDEA开发、测试、生产环境pom配置及使用
pom文件 一般放在最下面,project里 <!--开发环境.测试环境.生产环境--> <!--生产环境--> <profiles> <profile> ...
- linux I/O重定向及管道
一,I/O重定向 重定向正常输出 > :覆盖以存在文件的内容,很危险的操作 >>:如果文件已经存在,则是在原内容的最后追加. 可以禁止>的覆盖行为,使用set -C.只在当前会 ...
- 使用mysql-proxy实现mysql的读写分离
前言: MySQL读写分离是指让master处理写操作,让slave处理读操作,非常适用于读操作量比较大的场景,可减轻master的压力.使用mysql-proxy实现mysql的读写分离,mysq ...
- Java并发的若干基本陷阱、原理及解决方案
勿止于结论:持续探索与求证. 概述 为什么要使用并发 ? 有三点足够信服的理由: 性能提升.单核 CPU 的性能基本抵达瓶颈,充分挖掘多核 CPU 的能力,使得性能提升变成水平可扩展的. 事件本质.世 ...
- 【译】ModSecurity
Preface 本篇译ModSecurity 主页的自身介绍. ModSecurity is an open source, cross-platform web application firewa ...
- 利用WPF生成Q币充值二维码——扫码登录篇
一.前言 虽然腾讯官方不支持使用二维码充值Q币,但对于喜欢钻研的人来说这不是问题,本文利用WPF技术讲解从扫码登录到生成Q币充值二维码的一整套解决方案. 因为充值Q币需要先用QQ号登录官网.所以我们首 ...
- XNginx升级记录
之前的博文提到过,XNginx - nginx 集群可视化管理工具, 开发完成后一直稳定运行,直到前面因为一个站点的proxy站点配置问题,导致需要修改nginx 配置文件模板,因此借此机会对系统做了 ...
- IDEA 如何自动导入(import)
如果大家正在使用一个未曾导入(import)过的类,或者它的静态方法或者静态字段,IDEA 会给出对应的建议,只要按下 ⌥(option)和回车就可以接受建议. 但我觉得这样做仍然很麻烦,不够智能化. ...