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时代,文献复习阶段从各大数据库中搜集到的文献往往千头万绪.或重复或遗漏, ...
随机推荐
- Kubernetes 时代的安全软件供应链
点击下载<不一样的 双11 技术:阿里巴巴经济体云原生实践> 本文节选自<不一样的 双11 技术:阿里巴巴经济体云原生实践>一书,点击上方图片即可下载! 作者 汤志敏 阿里云 ...
- 全栈项目|小书架|微信小程序-实现搜索功能
效果图 上图是小程序端实现的搜索功能效果图. 从图中可以看出点击首页搜索按钮即可进入搜索页面. 布局样式是:搜索框 + 热搜内容 + 搜索列表. 搜索框使用 lin-ui 中的 Searchbar组件 ...
- 关于SQL Server 中日期格式化若干问题
select CONVERT(varchar, getdate(), 120 )2004-09-12 11:06:08 select replace(replace(replace(CONVERT(v ...
- luogu P4064 [JXOI2017]加法
题目描述 可怜有一个长度为 n 的正整数序列 A,但是她觉得 A 中的数字太小了,这让她很不开心. 于是她选择了 m 个区间 [li, ri] 和两个正整数 a, k.她打算从这 m 个区间里选出恰好 ...
- JsonModel的使用
本人最近在开发一款医疗类的APP 发现接口返回的数据很复杂 手动解析的话对新手来说就是一场灾难 在分解成所需要的model类型时工作量非常的大,于是从网上查阅相关资料,发现JsonModel这个第三方 ...
- 🔥🔥🔥Spring Cloud进阶篇之Eureka原理分析
前言 之前写了几篇Spring Cloud的小白教程,相信看过的朋友对Spring Cloud中的一些应用有了简单的了解,写小白篇的目的就是为初学者建立一个基本概念,让初学者在学习的道路上建立一定的基 ...
- BZOJ 3106: [cqoi2013]棋盘游戏
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 859 Solved: 356[Submit][Status][Discuss] Descriptio ...
- 洛谷 题解 P1351 【联合权值】
Problem P1351 [联合权值] record 用时: 99ms 空间: 13068KB(12.76MB) 代码长度: 3.96KB 提交记录: R9883701 注: 使用了 o1 优化 o ...
- Django 04
目录 视图层 三个常用方法 JsonResponse FBV 和 CBV 模板层 模板语法 模板传值 过滤器 标签 自定义过滤器和标签 模板的继承 模板的导入 视图层 三个常用方法 HttpRespo ...
- .Net Core使用Ocelot网关(二) -鉴权认证
前言 上一章已经简单的介绍了ocelot的使用了,但是网关暴露的接口如果什么人都能访问的话安全性就太低啦.所以我们需要去鉴权和认证.这里我们使用identityServer4给我们的网关来鉴权认证. ...