Add an Action that Displays a Pop-up Window 添加显示弹出窗口按钮
In this lesson, you will learn how to create an Action that shows a pop-up window. This type of Action is useful when you want a user to input several parameters in a pop-up dialog before an Action is executed.
在本课中,您将学习如何创建显示弹出窗口的操作。当您希望用户在执行操作之前在弹出对话框中输入多个参数时,这种类型的操作非常有用。
Note 注意
Before proceeding, take a moment to review the following lessons.
- Set a Many-to-Many Relationship (XPO/EF)
- Add a Simple Action
在继续之前,请花点时间复习以下课程。
- 设置多对多关系 (XPO/EF)
- 添加简单操作
Create a Controller and a PopupWindowShowAction
创建控制器和弹出窗口窗口显示操作
- Add a new View Controller to the MySolution.Module project, as described in the Add a Simple Action lesson. Name it PopupNotesController.
Right-click the MySolution.Module | Controllers | PopupNotesController.cs (PopupNotesController.vb) file, and choose View Designer to invoke the Designer.
向 MySolution.Module 项目添加新的视图控制器,如"添加简单操作"一课中所述。将其命名为"弹出笔记控制器"。
右键单击"我的解决方案"模块 |控制器 |PopupNotesController.cs (PopupNotesController.vb) 文件,然后选择"视图设计器"以调用设计器。
Drag the PopupWindowShowAction component from the DX.19.2: XAF Actions tab to the Designer. In the popupWindowShowAction1 "Properties" window, set the Name and Id properties to "ShowNotesAction", and set the Caption property to "Show Notes". Set the Category property to "Edit". This property specifies the Action group to which the current Action belongs. All Actions within a single group are displayed together sequentially in a UI.
将"弹出窗口显示操作"组件从 DX.19.2:XAF 操作选项卡拖动到设计器。在弹出窗口WindowShowAction1"属性"窗口中,将"名称"和"ID"属性设置为"显示笔记操作",并将标题属性设置为"显示注释"。将"类别"属性设置为"编辑"。此属性指定当前操作所属的操作组。单个组中的所有操作在 UI 中按顺序一起显示。
To activate the PopupNotesController for DemoTask Detail Views only, set the Controller's ViewController.TargetObjectType property to MySolution.Module.DemoTask, and set the ViewController.TargetViewType to DetailView.
要仅激活演示任务详细信息视图的 PopupNotes 控制器,请将控制器的视图控制器.TargetTotos 类型属性设置为 MySolution.module.demoTask,并将视图控制器.TargetViewType设置为详细信息视图。
Specify the Popup List View
指定弹出列表视图
Focus the ShowNotesAction component. In the Properties window, switch to the Events view. Double-click the CustomizePopupWindowParams event, add the "using" ("Imports" in VB) directive according to your ORM, and replace the auto-generated event handler code with the following code.
聚焦"显示笔记操作"组件。在"属性"窗口中,切换到"事件"视图。双击"自定义PopupWindowParams"事件,根据您的ORM在VB中添加"使用"("导入")指令,并将自动生成的事件处理程序代码替换为以下代码。
using DevExpress.Persistent.BaseImpl; //For XPO
using DevExpress.Persistent.BaseImpl.EF; //For EF
// ...
private void ShowNotesAction_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs args) {
IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(Note));
string noteListViewId = Application.FindLookupListViewId(typeof(Note));
CollectionSourceBase collectionSource = Application.CreateCollectionSource(objectSpace, typeof(Note), noteListViewId);
args.View = Application.CreateListView(noteListViewId, collectionSource, true);
//Optionally customize the window display settings.
//args.Size = new System.Drawing.Size(600, 400);
//args.Maximized = true;
//args.IsSizeable = false;
}
For details on this event, refer to the PopupWindowShowAction.CustomizePopupWindowParams topic. The code above will create the Notes List View when generating the pop-up window.
To create a List View, use the XafApplication object again (as you did in the previous lesson). In the code above, the XafApplication helps you find the ID of the required List View in the Application Model. Note that a collection source for the List View is created in a separate Object Space. To create the Object Space, use XafApplication again.
有关此事件的详细信息,请参阅弹出窗口窗口显示操作。生成弹出窗口时,上述代码将创建"备注列表视图"。
要创建列表视图,请再次使用 XafApplication 对象(如上一课所示)。在上面的代码中,Xaf 应用程序可帮助您在应用程序模型中找到所需列表视图的 ID。请注意,列表视图的集合源是在单独的对象空间中创建的。要创建对象空间,请再次使用 Xaf 应用程序。
Handle the Execute Event
处理执行事件
In the Controller's Designer, switch to the Events view in the Properties window with the Action's properties. Double-click the Execute event, add the "using" ("Imports" in VB) directive and replace the auto-generated event handler code with the following code.
在控制器的设计器中,切换到"属性"窗口中的"事件"视图,该视图具有操作的属性。双击 Execute 事件,在 VB 中添加"使用"("导入")指令,并将自动生成的事件处理程序代码替换为以下代码。
using MySolution.Module.BusinessObjects;
// ...
private void ShowNotesAction_Execute(object sender, PopupWindowShowActionExecuteEventArgs args) {
DemoTask task = (DemoTask)View.CurrentObject;
foreach(Note note in args.PopupWindowViewSelectedObjects) {
if(!string.IsNullOrEmpty(task.Description)) {
task.Description += Environment.NewLine;
}
task.Description += note.Text;
}
if(((DetailView)View).ViewEditMode == ViewEditMode.View) {
View.ObjectSpace.CommitChanges();
}
}
- The Execute event is raised when clicking the OK button in the pop-up window. When the handler above is executed, the Text property value of the selected Note object will be appended to the Task.Description property value.
- In this code, access the object selected in the pop-up window by using the event handler's PopupWindowShowActionExecuteEventArgs.PopupWindowViewSelectedObjects parameter.
- To refresh the editor representing the modified Description property, first find its PropertyEditor in the current View's CompositeView.Items collection using the CompositeView.FindItem method. To update the value displayed by the Property Editor's editor, call the PropertyEditor.ReadValue method.
- In ASP.NET Web applications, Detail Views are displayed in View and Edit modes. When the ShowNotes Action is activated for a DemoTask Detail View that is in View mode, the changes made to the DemoTask.Description property should be saved to the database. For this purpose, the CommitChanges method of the current View's ObjectSpace is called. When you use the ShowNotes Action in a DemoTask Detail View that is in Edit mode, the changes can be saved or rolled back via the corresponding built-in Actions.
- 单击弹出窗口中的"确定"按钮时引发"执行"事件。执行上述处理程序时,所选 Note 对象的 Text 属性值将追加到 Task.描述属性值。
- 在此代码中,使用事件处理程序的"弹出窗口显示操作执行事件"参数访问弹出窗口中选定的对象。
- 要刷新表示已修改的"描述"属性的编辑器,请首先在当前视图的"复合视图.项"集合中使用"复合视图.FindItem"方法查找其属性编辑器。要更新属性编辑器的编辑器显示的值,请调用属性编辑器.ReadValue 方法。
- 在ASP.NET Web 应用程序中,详细信息视图显示在"查看"和"编辑"模式下。当为处于"视图"模式的演示任务详细信息视图激活 ShowNotes 操作时,对 DemoTask.描述属性所做的更改应保存到数据库中。为此,将调用当前视图的对象空间的提交更改方法。在处于编辑模式的演示任务详细信息视图中使用 ShowNotes 操作时,可以通过相应的内置操作保存或回滚更改。
Add Notes to the UI
向 UI 添加注释
- To add the Note business class to the UI construction process, add it to the Application Model.
If your ORM is Entity Framework, you should register the Note type in DbContext before proceeding to the next step. Edit the BusinessObjects\MySolutionDbContext.cs file as shown below.
要将 Note 业务类添加到 UI 构造过程,请将其添加到应用程序模型中。
如果您的 ORM 是实体框架,则应在 DbContext 中注册 Note 类型,然后再继续执行下一步。编辑业务对象_MySolutionDbContext.cs 文件,如下所示。
public class MySolutionDbContext : DbContext {
//...
public DbSet<Note> Notes { get; set; }
}To add the Note business class from the Business Class Library use the Module Designer. Double-click the Module.cs (Module.vb) file within the MySolution.Module project. The Exported Types section of the designer lists the business classes that can be added.
要从商务舱库中添加 Note 业务类,请使用模块设计器。双击 MySolution.模块项目中的Module.cs(模块.vb)文件。设计器的"导出类型"部分列出了可添加的业务类。
If you are using XPO:
Locate the Referenced Assemblies | DevExpress.Persistent.BaseImpl.v19.2 | Note node.
- 如果您使用的是 XPO:
找到引用的程序集 |开发快车.持久.BaseImpl.v19.2 |注释节点。
If you are using Entity Framework:
Locate the Referenced Assemblies | DevExpress.Persistent.BaseImpl.EF.v19.2 | Note node.
- 如果您使用的是实体框架:
找到引用的程序集 |开发快车.持久.BaseImpl.EF.v19.2 |注释节点。
Select this node and press the SPACEBAR, or right-click it and choose Use Type in Application in the invoked context menu.
选择此节点并按空格键,或右键单击它,并在调用的上下文菜单中选择"在应用程序中使用类型"。
Build the project.
生成项目。
Note 注意
To create Note objects, you should add the Note item to the New Action's items. To do this, perform the steps demonstrated in the Add an Item to the New Action lesson.
To access the existing Note objects, add the Note item to the ShowNavigationItem Action's items (displayed by the navigation control). To do this, perform the steps demonstrated in the Add an Item to the Navigation Control lesson.
要创建 Note 对象,应将"注释"项添加到"新建操作"项中。为此,执行"将项目添加到新操作"一课中演示的步骤。
要访问现有的 Note 对象,将"注释"项添加到"显示导航项"操作的项目(由导航控件显示)。为此,执行"将项目添加到导航控制"一课中演示的步骤。
Result 结果
Run the WinForms or ASP.NET application. Create several Note objects via the New Action. Select the Task item in the navigation control. Double-click one of the listed Task objects. In the invoked detail form, find the Show Notes toolbar button that represents the implemented Action. Click this button, which will invoke a pop-up window. Select a Note object in the list and click OK. Check to see that the Task.Description property value has been changed.
运行 WinForms 或ASP.NET应用程序。通过"新建"操作创建多个 Note 对象。在导航控件中选择"任务"项。双击列出的任务对象之一。在调用的详细信息窗体中,查找表示已实现操作的"显示注释"工具栏按钮。单击此按钮,这将调用弹出窗口。在列表中选择"注意"对象,然后单击"确定"。检查任务描述属性值已更改。
Tip 提示
For an example of how to create and show a Detail View, refer to the How to: Create and Show a Detail View of the Selected Object in a Popup Window topic.
有关如何创建和显示详细信息视图的示例,请参阅"如何:在弹出窗口"主题中创建和显示选定对象的详细信息视图。
You can view the code demonstrated in this tutorial in the MySolution.Module | Controllers | PopupNotesController.cs (PopupNotesController.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.模块中演示的代码。控制器 |PopupNotesController.cs (PopupNotes控制器.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 an Action that Displays a Pop-up Window 添加显示弹出窗口按钮的更多相关文章
- Flex弹出窗口请求Action函数
Flex弹出窗口请求Action函数 private function askQuestion(event:MouseEvent):void { var askQuestions:AskWindow ...
- iOS开发技巧 - 使用Alerts和Action Sheets显示弹出框
解决方案: (Swift) 使用UIAlertController类 (Objective-C) 使用UIAlertView类 代码: (Swift) import UIKit class ViewC ...
- Add an Action with Option Selection 添加具有选项选择的按钮
In this lesson, you will learn how to create an Action with support for option selection. A new View ...
- 3D Touch开发全面教程之Peek and Pop - 预览和弹出
## 3D Touch开发全面教程之Peek and Pop - 预览和弹出 --- ### 了解3D Touch 在iPhone 6s和iPhone 6s Plus中Apple引入了3D Touch ...
- Android 使用弹出对话框,报Unable to add window错误
今天在使用Android弹出对话框的时候,报了一个unable to add window错误,我的代码如下 new AlertDialog.Builder(getApplicationContext ...
- 达到J2EE在后台action控制接待javascript弹出的对话框
1.后台Action于: request.setAttribute("message", "这项username要么password错误,请重新输入!"); 2 ...
- ASP.NET查询页面设置form的action属性只弹出一个页面,并且每次将页面设置到最前
原文:ASP.NET查询页面设置form的action属性只弹出一个页面,并且每次将页面设置到最前 背景 当数据量大.查询条件复杂,多样多的时候,我们可能需要单独做一个查询界面,当用户选择设置了相关的 ...
- 网页上弹出pop窗口实例,(document).height()与$(window).height()的区别
#dvbg{background-color:#666666; position:absolute; z-index:99; left:0; top:0; display:none; width:10 ...
- Python3基础 dict pop 弹出指定键的项
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
随机推荐
- mybatis源码学习(二)--mybatis+spring源码学习
这篇笔记主要来就,mybatis是如何利用spring的扩展点来实现和spring的整合 1.mybatis和spring整合之后,我们就不需要使用sqlSession.selectOne()这种方式 ...
- Provider模式应用demo
参考ObjectPool对象池设计原理还原一个简易的Provider模式. using System; using System.Dynamic; using System.Reflection.Me ...
- 在 Spring Boot 项目中使用 activiti
新建springBoot项目时勾选activiti,或者在已建立的springBoot项目添加以下依赖: <dependency> <groupId>org.activiti& ...
- 12-Factor与云原生
12-Factor与云原生 云原生应用 今天先到这儿,希望对技术领导力, 企业管理,系统架构设计与评估,团队管理, 项目管理, 产品管理,团队建设 有参考作用 , 您可能感兴趣的文章: 精益IT组织与 ...
- ABAP基础语法
1.数据类型及属性 类型 说明 C N 0到9之间字符组成的数字字符串 D 日期格式必须为 YYYYMMDD T 格式为 24-hour的 HHMMSS I -2.147.483.648 to +2. ...
- Shell(七):文件包含
和其他语言一样,Shell 也可以包含外部脚本(类似python中import的功能).这样可以很方便的封装一些公用的代码作为一个独立的文件. Shell 文件包含的语法格式如下: . filenam ...
- 基于H7的串口WIFI模块ESP8266的TCP客户端例子和操作说明(AP兼STA模式)
说明: 1.如果不熟悉网络的话,等我这几天更新V7用户手册的ESP8266章节,如果熟悉的话,直接操作即可,这里将操作说明发出来. 2.串口WIFI是采用的AT指令操作,简单易用,指令手册在这个帖子里 ...
- C#构造方法(构造函数)
构造方法特点: 一 ,与类同名 public class Product { public int ID { get; set; } public String NAME { get; set; } ...
- centos7上安装jdk1.8
我这里是使用的jdk1.8:由于vmware上的字体太小,所以我使用xShell链接linux系统进行操作的. 准备工作:使用xftp链接linux系统:然后创建个包将linux版本的jdk上传上去: ...
- Spring(4)AOP
Spring(4)AOP 1.AOP概述 在软件业,AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功能的统一维护的一种 ...