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. 转自自己的关于落谷计数器【p1239】的题解

    本蒟蒻写这道题用了两天半里大概五六个小时.(我太弱了) 然后这篇题解将写写我经历的沟沟坎坎,详细的分析一下, 但是由于它很长,因此一定还有多余的地方,比如说我的 预处理,可能比较多余.但是我觉得,信息 ...

  2. 用函数式编程,从0开发3D引擎和编辑器(二):函数式编程准备

    大家好,本文介绍了本系列涉及到的函数式编程的主要知识点,为正式开发做好了准备. 函数式编程的优点 1.粒度小 相比面向对象编程以类为单位,函数式编程以函数为单位,粒度更小. 正所谓: 我只想要一个香蕉 ...

  3. WinForm自定义控件之DefaultValue的误解

    DefaultValue,顾名思义,默认值的意思.但这个默认值不是用来显示的,它的作用是当属性设置的值(无法代码写还是属性窗口输入)与DefaultValue相同时,会区别显示,比如其它值加粗,Def ...

  4. 如何Windows下配置Prometheus的监控数据文件为3天

    如上图,prometheus的data文件夹时间久了会变得很大,听说是保留15天的数据.但是实际上,我只需要保留3天的数据就够了,之前试过用批处理文件清理,但是强行删除会导致peometheus崩溃, ...

  5. idea使用maven中的tomcat插件开启服务出现java.net.BindException: Address already in use: JVM_Bind :8080错误原因

    [INFO] create webapp with contextPath: /maven_web 五月 11, 2019 6:05:26 下午 org.apache.coyote.AbstractP ...

  6. 配置Postman通过OAuth 2 implicit grant获取Dynamics 365 CE Online实例的Access Token

    微软动态CRM专家罗勇 ,回复335或者20190516可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me. 对于测试Web API, Get 类型,不需要设定特别reque ...

  7. Vue 中的keep-alive 什么用处?

    keep-alive keep-alive是Vue提供的一个抽象组件,用来对组件进行缓存,从而节省性能,由于是一个抽象组件,所以在v页面渲染完毕后不会被渲染成一个DOM元素 <keep-aliv ...

  8. RCS MO_Client&server Net log 摘录

          传输过程总体来说: (1)客户端提供[客户端随机数.可选算法套件.sessionId]等信息 (2)服务端提供[服务端随机数.选用算法套件.sessionId]等信息 (3)服务端提供证书 ...

  9. ksoap2 android 调用WebService

    webService,soap,wsdl的基本概念? 详情请看维基百科 基于soap 1.1, soap 1.2 的请求和响应数据源 查找了很久都是基于json格式传输数据,但是最终还是找到了基于xm ...

  10. golang.org 安装脚本

    #!/usr/bin/env bash cd $GOPATH; #创建 $GOPATH/src/golang.org/x 目录 mkdir -p $GOPATH/src/golang.org/x; e ...