In this lesson, you will learn how to add a Parametrized Action. These types of Actions are slightly more complex than the Simple Actions you learned about in the previous lesson. The Parametrized Action provides an editor, so that an end-user can input a value before execution. In this lesson, a new View Controller will be implemented and a new Parametrized Action will be added to it. This Action will search for a DemoTask object by its Subject property value, and display the found object on a detail form.

在本课中,您将学习如何添加参数化操作。这些类型的操作比您在上一课中学到的简单操作稍微复杂一些。参数化操作提供编辑器,以便最终用户可以在执行之前输入值。在本课中,将实现一个新的视图控制器,并将向其添加新的参数化操作。此操作将按其"主题"属性值搜索 DemoTask 对象,并在详细信息窗体上显示找到的对象。

Note  注意

Before proceeding, take a moment to review the following lessons.

  • Inherit from the Business Class Library Class (XPO/EF)
  • Initialize a Property After Creating an Object (XPO/EF)
  • Add a Simple Action
  • Add a new View Controller to the MySolution.Module project, as described in the Add a Simple Action lesson. Name it FindBySubjectController.
  • Right-click the newly created MySolution.Module | Controllers | FindBySubjectController.cs (FindBySubjectController.vb) file, and choose View Designer to invoke the Designer. Drag ParametrizedAction from the DX.19.2: XAF Actions Toolbox tab to the Designer. In the ParametrizedAction Properties window, set the Name and ID properties to "FindBySubjectAction", and set the Caption property to "Find Task by Subject".

在继续之前,请花点时间复习以下课程。

  • 从商务舱库类 (XPO/EF) 继承

  • 创建对象后初始化属性 (XPO/EF)
  • 添加简单操作
  • 向 MySolution.Module 项目添加新的视图控制器,如"添加简单操作"一课中所述。将其命名为"查找主体控制器"。
  • 右键单击新创建的 MySolution.模块 |控制器 |FindBySubjectController.cs (FindBySubjectController.vb) 文件,然后选择"视图设计器"以调用设计器。将参数化操作从 DX.19.2:XAF 操作工具箱选项卡拖动到设计器。在"参数化操作属性"窗口中,将"名称"和"ID"属性设置为"查找按主题操作",并将"标题"属性设置为"按主题查找任务"。

  • To activate the FindBySubjectController with its FindBySubjectAction for DemoTask List Views only, set the ViewController.TargetViewType property to "ListView", and set ViewController.TargetObjectType to MySolution.Module.DemoTask via the Controller's Properties window. To activate the Controller for root Views only, set the ViewController.TargetViewNesting property to Root.

  • 要激活 FindBy 主题控制器,其 FindBySubject 操作仅针对演示任务列表视图,请将"视图控制器.TargetViewType"属性设置为"listView",并将视图控制器.TargetObjectType 设置为 MySolution.module.DemoTask控制器的属性窗口。要仅激活根视图的控制器,请将"视图控制器.TargetViewNesting"属性设置为 root。

  • Next, you need to handle the Action's ParametrizedAction.Execute event to implement the search functionality. Focus the FindBySubject Action in the Controller's Designer. Switch to the Events view in the Properties window. Double-click the Execute event, replace the auto-generated event handler code with the following.

  • 接下来,您需要处理操作的参数化操作。在控制器的设计器中集中查找主体操作。切换到"属性"窗口中的"事件"视图。双击 Execute 事件,将自动生成的事件处理程序代码替换为以下内容。

    private void FindBySubjectAction_Execute(object sender, ParametrizedActionExecuteEventArgs e) {
    IObjectSpace objectSpace = Application.CreateObjectSpace(((ListView)View).ObjectTypeInfo.Type);
    string paramValue = e.ParameterCurrentValue as string;
    object obj = objectSpace.FindObject(((ListView)View).ObjectTypeInfo.Type,
    CriteriaOperator.Parse(string.Format("Contains([Subject], '{0}')", paramValue)));
    if(obj != null) {
    DetailView detailView = Application.CreateDetailView(objectSpace, obj);
    detailView.ViewEditMode = DevExpress.ExpressApp.Editors.ViewEditMode.Edit;
    e.ShowViewParameters.CreatedView = detailView;
    }
    }

    The Execute event is raised after a parameter has been typed in the Action's editor. The handler above looks for the DemoTask object, whose subject contains the text specified as a parameter, and invokes the detail form for this object.

在操作的编辑器中键入参数后,将引发 Execute 事件。上面的处理程序查找 DemoTask 对象,其主题包含指定为参数的文本,并调用此对象的详细信息形式。

Note 注意
  • To search for an object, you will need an Object Space. The Object Space is always used when manipulating persistent objects. To use the Object Space in this task, create it using the XafApplication.CreateObjectSpace method. Since an application is accessible nearly everywhere in code, its CreateObjectSpace method is always helpful.
  • 要搜索对象,您需要一个对象空间。操作持久对象时始终使用对象空间。要在此任务中使用对象空间,请使用 Xaf 应用程序.CreateObjectSpace 方法创建它。由于应用程序几乎可以在代码的任何地方访问,因此其 CreateObjectSpace 方法始终很有用。
  • To use the IObjectSpace.FindObject method, pass the type of the searched object, along with its criteria. To get the type of the objects represented in the current List View, use the View's object type info (see View.ObjectTypeInfo). To generate a criterion, create a BinaryOperator object by passing criteria components as the constructor's parameters. For additional information, refer to the Querying a Data Store section in the XPO documentation.
  • 要使用 IObjectSpace.FindObject 方法,传递搜索对象的类型及其条件。要获取当前列表视图中表示的对象类型,请使用视图的对象类型信息(请参阅 View.ObjectTypeInfo)。要生成条件,请通过将条件组件作为构造函数的参数来创建 BinaryOperator 对象。有关详细信息,请参阅 XPO 文档中的"查询数据存储"部分。
  • To get the value entered by an end-user in the editor that represents the FindBySubjectAction, use the event handler's ParametrizedActionExecuteEventArgs.ParameterCurrentValue parameter.
  • 要获取最终用户在编辑器中输入的值,该编辑器表示 FindBySubjectAction 操作,请使用事件处理程序的参数化操作执行事件Args.参数电流值参数。
  • To show the found object in a separate Detail View, create the View via the XafApplication.CreateDetailView method and assign it to the ShowViewParameters.CreatedView property of the event handler's ActionBaseEventArgs.ShowViewParameters parameter. Show View Parameters can be initialized in the Execute event handler of an Action of any type, so you can always show a View after Action execution. For additional information on how to show a View in a separate window, refer to the Ways to Show a View topic.
  • 要在单独的详细视图中显示找到的对象,请通过 Xaf 应用程序创建视图.创建详细信息视图方法并将其分配给 ShowView 参数.事件处理程序的 ActionBaseEventAgs.ShowView 参数的 CreateView 属性。可以在任何类型的操作的"执行事件"处理程序中初始化显示视图参数,因此始终可以在操作执行后显示视图。有关如何在单独的窗口中显示视图的其他信息,请参阅显示视图的方法主题。
  • As you may have already noticed, the XafApplication object is useful when you need to create a List View, Detail View, Object Space, etc. The XAFApplication object is accessible from many locations in an XAF application. In Controllers, it can be accessed via the Controller.Application property.
  • 您可能已经注意到,当您需要创建列表视图、详细信息视图、对象空间等时,XafApplication 对象非常有用。XAF 应用程序对象可从 XAF 应用程序中的许多位置访问。在控制器中,可以通过控制器.应用程序属性访问它。
  • Run the WinForms or ASP.NET application. Select the Task item in the navigation control. Find the Find Task by Subject editor that represents the Action you have implemented. Type a word from an existing DemoTask object's Subject property into this editor. Press the Enter key or click Find Task by Subject. A detail form with this object will be displayed.

  • 运行 WinForms 或ASP.NET应用程序。在导航控件中选择"任务"项。查找"按主题查找任务"编辑器,该编辑器表示已实现的操作。在此编辑器中键入现有 DemoTask 对象的"主题"属性中的单词。按 Enter 键或单击"按主题查找任务"。将显示具有此对象的详细信息窗体。

You can see the code demonstrated here in the MySolution.Module | Controllers | FindBySubjectController.cs (FindBySubjectController.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.模块 |控制器 |FindBySubjectController.cs (FindBy主题控制器.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 Parametrized Action 添加带参数的按钮的更多相关文章

  1. Add a Simple Action添加简单按钮

    In this lesson, you will learn how to create a Simple Action. For this purpose, a new View Controlle ...

  2. form表单提交时,action怎么带参数

    <html> <title>form</title> <script type="text/javascript"> functio ...

  3. 在C#中怎么调用带参数的存储过程啊??

    1)执行一个没有参数的存储过程的代码如下:SqlConnection conn=new SqlConnection(“connectionString”);SqlDataAdapter da = ne ...

  4. egret之移除带参数的监听事件

    this.selectBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickNewIndo.bind(this,this.data) ...

  5. 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 Vie ...

  6. Flex 关于 keyDown事件的添加和移除(另附添加事件的执行带参数的函数)

    今天遇到一个棘手的问题,原本的textInput控件有一个keyDown事件,但是不是所有的用户都需要,麻烦了首先先删除控件里面的keyDown,这个事件放在这谁都得用,我就是不想用这就实现不了,怎么 ...

  7. 【笔记】Asp.Net WebApi对js POST带参数跨域请求的支持方案

    先说下需求:在原来的WebApi项目中增加对js跨域的请求支持,请求方式:以POST为主,webapi路由规则根据原项目需求修改如下: public static void Register(Http ...

  8. Struts2之Action接收请求参数和拦截器

    技术分析之在Struts2框架中使用Servlet的API        1. 在Action类中也可以获取到Servlet一些常用的API        * 需求:提供JSP的表单页面的数据,在Ac ...

  9. ASP.NET Boilerplate 学习 AspNet Core2 浏览器缓存使用 c#基础,单线程,跨线程访问和线程带参数 wpf 禁用启用webbroswer右键菜单 EF Core 2.0使用MsSql/MySql实现DB First和Code First ASP.NET Core部署到Windows IIS QRCode.js:使用 JavaScript 生成

    ASP.NET Boilerplate 学习   1.在http://www.aspnetboilerplate.com/Templates 网站下载ABP模版 2.解压后打开解决方案,解决方案目录: ...

随机推荐

  1. LeetCode刷题总结-字符串篇

    本文梳理对LeetCode上有关字符串习题的知识点,并给出对应的刷题建议.本文建议刷题的总数为32题.具体知识点如下图: 1.回文问题 题号:5. 最长回文子串,难度中等 题号:214. 最短回文串, ...

  2. 使用Power BI API 向流数据集推送实时数据并在仪表板可视化

    使用Power BI 实现实时数据的可视化是大家比较关心的一个话题,在仪表盘上实现推送数据的展示,可以在诸如指挥大屏等场景下使用. 本视频实战内容如下: https://v.qq.com/x/page ...

  3. Java连载62-使用throws关键字处理异常

    ​一.处理异常的两种方式 1.所有的编译时异常,要求程序员在编写程序阶段,必须对它进行处理,如果不处理的话,编译就会无法通过,处理异常有两种方法:捕捉和声明抛出. 2.捕捉:try.....catch ...

  4. jQuery实现简单购物车页面

    功能描述: 当全选按钮被按下时,所有商品的小复选框(以及另外一个全选按钮)的选中状态跟按下的全选按钮保持一致: 当用户选中商品时,如果所有商品都被选中,就让全选按钮为选中状态: 用户可以点击 + - ...

  5. 使用react-app-rewired和customize-cra对默认webpack自定义配置

    最近在学习react框架,之前一直都是用vue 开发,知道在vue 中知道如何配置一下相关的webpack 有助于开发,学react 过程中,我也在想这些该怎么配置啊,所以就有这篇文章. 这篇文章主要 ...

  6. Vue+Webpack之 代码及打包优化

    本文重点介绍Vue单页面应用的优化手段: 异步加载 面切换时加loading特效 点击延迟 inline manifest 逻辑代码优化 依赖包体积优化 cdn引用 Vue代码优化 异步加载 所谓的异 ...

  7. 南邮CTF - Writeup

    南邮CTF攻防平台Writeup By:Mirror王宇阳 个人QQ欢迎交流:2821319009 技术水平有限~大佬勿喷 ^_^ Web题 签到题: 直接一梭哈-- md5 collision: 题 ...

  8. Cesium专栏-Billboard加载Gif图片

    Cesium 是一款面向三维地球和地图的,世界级的JavaScript开源产品.它提供了基于JavaScript语言的开发包,方便用户快速搭建一款零插件的虚拟地球Web应用,并在性能,精度,渲染质量以 ...

  9. Cordova搭建,所遇到问题处理

    环境:NodeJs.[Android SDK | IOS] 安装:npm install -g cordova 过程: 1.创建一个项目:cordova create myApp 2.选择平台: co ...

  10. 【ftp服务】配置ftp用户不能返回上级目录,只能在指定的目录

    500 OOPS: vsftpd: both local and anonymous access disabled! 出现这个错,需要修改配置:local_enable=YES 500 OOPS: ...