How to: Display a List of Non-Persistent Objects in a Popup Dialog 如何:在弹出对话框中显示非持久化对象列表
This example demonstrates how to populate and display a list of objects that are not bound to the database (non-persistent objects). A sample application that stores a list of books will be created in this example. An Action that displays a list of duplicate books in a pop-up window will be added to this application.
此示例演示如何填充和显示未绑定到数据库的对象(非持久性对象)的列表。此示例中将创建一个存储书籍列表的示例应用程序。在弹出窗口中显示重复书籍列表的操作将添加到此应用程序。
Note 注意
Mobile applications do not show objects from collection properties in Detail Views. To implement this functionality in the Mobile UI, show a List View as described in the How to: Display a Non-Persistent Object's List View from the Navigation topic.
移动应用程序不会在"详细信息视图"中显示来自集合属性的对象。要在移动 UI 中实现此功能,请查看"如何:从导航主题显示非持久性对象的列表视图"中所述的列表视图。
Tip 提示
A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E980
完整的示例项目可在 DevExpress 代码示例数据库中找到,http://www.devexpress.com/example=E980
.
1.Define the Book persistent class.
定义书籍持久性类。
[DefaultClassOptions]
public class Book : BaseObject {
public Book(Session session) : base(session) { }
public string Title {
get { return GetPropertyValue<string>(nameof(Title)); }
set { SetPropertyValue<string>(nameof(Title), value); }
}
}
The Book class, as its name implies, is used to represent books. It inherits BaseObject, and thus it is persistent. It contains a single Title property, which stores a book's title.
书类,顾名思义,是用来代表书籍的。它继承 BaseObject,因此它是永久性的。它包含一个标题属性,该属性存储书籍的标题。
2.Define two non-persistent classes - Duplicate and DuplicatesList.
定义两个非持久性类 - 重复类和重复类列表。
[DomainComponent]
public class Duplicate {
[Browsable(false), DevExpress.ExpressApp.Data.Key]
public int Id;
public string Title { get; set; }
public int Count { get; set; }
}
[DomainComponent]
public class DuplicatesList {
private BindingList<Duplicate> duplicates;
public DuplicatesList() {
duplicates = new BindingList<Duplicate>();
}
public BindingList<Duplicate> Duplicates { get { return duplicates; } }
}
Note 注意
The INotifyPropertyChanged , IXafEntityObject and IObjectSpaceLink interface implementations were omitted in this example. However, it is recommended to support these interfaces in real-world applications (see PropertyChanged Event in Business Classes and Non-Persistent Objects).These classes are not inherited from an XPO base persistent class, and are not added to the Entity Framework data model. As a result, they are not persistent. The DomainComponentAttribute applied to these classes indicates that these classes should be added to the Application Model and thus will participate in UI construction. The Duplicate non-persistent class has three public properties - Title, Count and Id. The Title property stores the title of a book. The Count property stores the total number of books with the title specified by the Title property. Id is a key property. It is required to add a key property to a non-persistent class and provide a unique key property value for each class instance in order for the ListView to operate correctly. To specify a key property, use the KeyAttribute. The DuplicatesList non-persistent class aggregates the duplicates via the Duplicates collection property of the BindingList<Duplicate> type.
本例中省略了INotifyPropertyChanged、IXafEntityObject和IObjectSpaceLink接口实现。但是,建议在实际应用程序中支持这些接口(请参阅业务类和非持久性对象中的属性更改事件)。这些类不是从 XPO 基基持久类继承的,也不会添加到实体框架数据模型中。因此,它们不是持久的。应用于这些类的域组件属性指示这些类应添加到应用程序模型中,从而将参与 UI 构造。重复的非持久性类有三个公共属性 - 标题、计数和 ID。"标题"属性存储书籍的标题。"Count"属性存储具有"标题"属性指定的帐簿总数。Id 是密钥属性。需要将键属性添加到非持久性类,并为每个类实例提供唯一的键属性值,以便 ListView 能够正常运行。要指定键属性,请使用"键属性"。复制列表非持久性类通过 BindingList<Duplicate> 类型的重复集合属性聚合重复项。
3.Create the following ShowDuplicateBooksController View Controller.
创建以下显示复制书控制器视图控制器。
public class ShowDuplicateBooksController : ObjectViewController<ListView, Book> {
public ShowDuplicateBooksController() {
PopupWindowShowAction showDuplicatesAction =
new PopupWindowShowAction(this, "ShowDuplicateBooks", "View");
showDuplicatesAction.CustomizePopupWindowParams += showDuplicatesAction_CustomizePopupWindowParams;
}
void showDuplicatesAction_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e) {
Dictionary<string, int> dictionary = new Dictionary<string, int>();
foreach(Book book in View.CollectionSource.List) {
if(!string.IsNullOrEmpty(book.Title)) {
if(dictionary.ContainsKey(book.Title)) {
dictionary[book.Title]++;
}
else
dictionary.Add(book.Title, );
}
}
var nonPersistentOS = Application.CreateObjectSpace(typeof(DuplicatesList));
DuplicatesList duplicateList =nonPersistentOS.CreateObject<DuplicatesList>();
int duplicateId = ;
foreach(KeyValuePair<string, int> record in dictionary) {
if (record.Value > ) {
var dup = nonPersistentOS.CreateObject<Duplicate>();
dup.Id = duplicateId;
dup.Title = record.Key;
dup.Count = record.Value;
duplicateList.Duplicates.Add(dup);
duplicateId++;
}
}
nonPersistentOS.CommitChanges();
DetailView detailView = Application.CreateDetailView(nonPersistentOS, duplicateList);
detailView.ViewEditMode = DevExpress.ExpressApp.Editors.ViewEditMode.Edit;
e.View = detailView;
e.DialogController.SaveOnAccept = false;
e.DialogController.CancelAction.Active["NothingToCancel"] = false;
}
}
This Controller inherits ObjectViewController<ListView, Book>, and thus, targets List Views that display Books. In the Controller's constructor, the ShowDuplicateBooksPopupWindowShowAction is created. In the Action's PopupWindowShowAction.CustomizePopupWindowParams event handler, the Books are iterated to find the duplicates. For each duplicate book found, the Duplicate object is instantiated and added to the DuplicatesList.Duplicates collection. Note that a unique key value (Id) is assigned for each Duplicate. Finally, a DuplicatesList Detail View is created and passed to the handler's CustomizePopupWindowParamsEventArgs.View parameter. As a result, a DuplicatesList object is displayed in a pop-up window when a user clicks ShowDuplicateBooks.
此控制器继承对象视图控制器[列表视图,Book],因此,目标列表视图显示书籍。在控制器的构造函数中,将创建"显示复制书"PopupWindowShowAction。在操作的"弹出窗口窗口显示操作"中,自定义PopupWindowParams事件处理程序,将迭代"书籍"以查找重复项。对于找到的每个重复书籍,复制对象将实例化并添加到重复列表。请注意,为每个副本分配了唯一的键值 (Id)。最后,创建一个重复列表详细信息视图,并将其传递给处理程序的"自定义弹出窗口"ParamsEventArgs.View 参数。因此,当用户单击"显示复制书"时,在弹出窗口中将显示一个重复列表对象。
The following images illustrate the implemented Action and its pop-up window.
下图说明了实现的操作及其弹出窗口。
Windows Forms:
窗口窗体:
ASP.NET:
How to: Display a List of Non-Persistent Objects in a Popup Dialog 如何:在弹出对话框中显示非持久化对象列表的更多相关文章
- 解决display none到display block 渲染时间过长的问题,以及bootstrap模态框导致其他框中input不能获得焦点问题的解决
在做定制页面的时候,遇到这么一个问题,因为弹出框用的是bootstrap的自带的弹出框,控制显示和隐藏也是用自带的属性控制 控制显示,在触发的地方 例如botton上面加上 data-toggle=& ...
- Ecstore后台中显示页面display,page,singlepage方法的区别?
dispaly 显示的页面不包含框架的其他页面,只是本身的页面(使用范围:Ecstore的前端.后端). page 显示的页面包含在框架的里面(使用范围:Ecstore的前端.后端). singlep ...
- 完美解决xhost +报错: unable to open display "" 装oracle的时候总是在弹出安装界面的时候出错
详细很多朋友在装oracle的时候总是在弹出安装界面的时候出错,界面就是蹦不出来. oracle安装 先切换到root用户,执行xhost + 然后再切换到oracle用户,执行export DISP ...
- table中tr的display属性在火狐中显示不正常,IE中显示正常
最近在作项目的时候碰到一个问题,就是需要AJAX来交互显示<tr> </tr> 标签内的东西,按照常理,对于某一单元行需要显示时,使用:display:block属性,不需要显 ...
- tr设置display属性时,在FF中td合并在第一个td中显示的问题
今天用firefox测试页面的时候,发现用javascript控制 tr 的显示隐藏时,当把tr的显示由“display:none”改为“display:block”时,该tr下的td内容合并到了 ...
- ADD software version display
ADD software version display ADD software version display1. Problem Description2. Analysis3. Solutio ...
- 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 Acti ...
- 使用 WSO2 API Manager 管理 Rest API
WSO2 API Manager 简介 随着软件工程的增多,越来越多的软件提供各种不同格式.不同定义的 Rest API 作为资源共享,而由于这些 API 资源的异构性,很难对其进行复用.WSO2 A ...
- paper 77:[转载]ENDNOTE使用方法,常用!
一.简介 EndNote是一款用于海量文献管理和批量参考文献管理的工具软件,自问世起就成为科研界的必备武器.在前EndNote时代,文献复习阶段从各大数据库中搜集到的文献往往千头万绪.或重复或遗漏, ...
随机推荐
- Python基础班学习笔记
本博客采用思维导图式笔记,所有思维导图均为本人亲手所画.因为本人也是初次学习Python语言所以有些知识点可能不太全. 基础班第一天学习笔记:链接 基础班第二天学习笔记:链接 基础班第三天学习笔记:链 ...
- luogu P1840 Color the Axis_NOI导刊2011提高(05)|并查集
题目描述 在一条数轴上有N个点,分别是1-N.一开始所有的点都被染成黑色.接着我们进行M次操作,第i次操作将[Li,Ri]这些点染成白色.请输出每个操作执行后剩余黑色点的个数. 输入格式 输入一行为N ...
- APP Distribution Guide 苹果官网
https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/Introduct ...
- React 事件总结
目录 一 绑定事件处理函数 1.1 鼠标类 1.2 拖拽事件: 1.3 触摸 1.4 键盘 1.5 剪切类 1.6 表单类 1.7 焦点事件 1.8 UI元素类 1.9 滚动 1.10 组成事件 1. ...
- Mybatis底层源码分析
MyBatis 流程图 Configuration.xml 该配置文件是 MyBatis 的全局配置文件,在这个文件中可以配置诸多项目.常用的内容是别名设置,拦截器设置等. Properties(属性 ...
- BOM对象学习
location,history,screen <!DOCTYPE html> <html> <head> <meta charset="utf-8 ...
- BZOJ11208 宠物收养所
最近,阿Q开了一间宠物收养所.收养所提供两种服务:收养被主人遗弃的宠物和让新的主人领养这些宠物.每个领养者都希望领养到自己满意的宠物,阿Q根据领养者的要求通过他自己发明的一个特殊的公式,得出该领养者希 ...
- 2017 ACM/ICPC 沈阳 I题 Little Boxes
Little boxes on the hillside. Little boxes made of ticky-tacky. Little boxes. Little boxes. Little b ...
- FPGA_VIP_V101 视频开发板 深入调试小结
FPGA_VIP_V101 推出已经有半年有余,各项功能例程已移植完毕,主要参考crazybingo例程进行移植和结合开发板设计了几个实例例程 主要包含: 硬件配置: FPGA:EP4CE6E22C8 ...
- JS中的深拷贝和浅拷贝
浅拷贝 浅拷贝是拷贝第一层的拷贝 使用Object.assign解决这个问题. let a = { age: 1 } let b = Object.assign({}, a) a.age = 2 co ...