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. LImax服务器框架学习--安装、使用ant工具、生成limax相关代码

    一.安装ant ant 是一个将软件编译.测试.部署等步骤联系在一起加以自动化的一个工具,大多用于Java环境中的软件开发.在实际软件开发中,有很多地方可以用到ant. 首先现在一个ant安装压缩包, ...

  2. [ASP.NET Core 3框架揭秘] 依赖注入[8]:服务实例的生命周期

    生命周期决定了IServiceProvider对象采用怎样的方式提供和释放服务实例.虽然不同版本的依赖注入框架针对服务实例的生命周期管理采用了不同的实现,但总的来说原理还是类似的.在我们提供的依赖注入 ...

  3. SAP QA32试图做UD,系统报错-工厂 BTYC中的 QM 基选设置需要维护

    SAP QA32 试图做UD,系统报错 - 工厂 BTYC 中的 QM 基选设置需要维护 - 检验批 10000062593,试图做使用决策,系统报错, 工厂 BTYC 中的 QM 基选设置需要维护 ...

  4. Android中Parcelable的使用

    转载请标明出处 :https://www.cnblogs.com/tangZH/p/10998065.html  Parcelable与Serializable Serializable是Java为我 ...

  5. Unity-使用UnityRemote调试手机Android Studio打印日志

    抛出问题:  1.Unity调试Android的时候默认情况是build打包成apk,安装到手机运行,调试起来很不方便,如何快速在手机上运行呢?  2.如何像unity的console一样在andro ...

  6. P1983 车站分级 思维+拓扑排序

    很久以前的一道暑假集训的题,忘了补. 感觉就是思维建图,加拓扑排序. 未停靠的火车站,必然比停靠的火车站等级低,就可以以此来建边,此处注意用vis来维护一下,一个起点和终点只建立一条边,因为不这样的话 ...

  7. 利用WPF生成Q币充值二维码——扫码登录篇

    一.前言 虽然腾讯官方不支持使用二维码充值Q币,但对于喜欢钻研的人来说这不是问题,本文利用WPF技术讲解从扫码登录到生成Q币充值二维码的一整套解决方案. 因为充值Q币需要先用QQ号登录官网.所以我们首 ...

  8. 防止sql注入的最好方式

    避免 SQL injection 攻击的传统方法之一是,把它作为一个输入合法性检查的问题来处理,只接受列在白名单中的字符,或者识别并避免那些列在黑名单中的恶意数据.白名单方法是一种非常有效方法,它可以 ...

  9. opengl画不出直线 线段 坐标轴 却能画出其他图形的坑

    原文作者:aircraft 原文链接:https://www.cnblogs.com/DOMLX/p/12054507.html 好多次都是画坐标轴的三条直线画不出来,虽然最后都解决了  但是还是耽误 ...

  10. 基于webpack实现多html页面开发框架七 引入第三方库如jquery

    一.解决什么问题 1.如何引入第三方库,如jquery等 二.引入jquery方法 1.下载jquery.min.js放到assets/lib下面 2.安装copy-webpack-plugin,将已 ...