How to: Display a Non-Persistent Object's List View from the Navigation
This example demonstrates how to display a non-persistent object's List View when a navigation item is chosen. Note that this approach is compatible with the Client data access mode only.
Declare a non-persistent class (e.g., MyNonPersistentObject ), and decorate it with the DomainComponentAttribute and DefaultClassOptionsAttribute attributes.
C#VBusing DevExpress.ExpressApp.DC;
using DevExpress.Persistent.Base;
// ...
[DomainComponent, DefaultClassOptions]
public class MyNonPersistentObject {
// ...
}NoteFor simplicity, implementation of the INotifyPropertyChanged, IXafEntityObject and IObjectSpaceLink interfaces are 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).
Open the WinApplication.cs (WinApplication.vb) and/or WebApplication.cs (WebApplication.vb) code. Ensure that the NonPersistentObjectSpaceProvider is registered in the overriddenCreateDefaultObjectSpaceProvider method (in addition to the existing XPObjectSpaceProvider or EFObjectSpaceProvider). Currently, this code is added automatically by the Solution Wizard, but it may be missing if you have created your project using an older version of XAF.
C#VBprotected override void CreateDefaultObjectSpaceProvider(CreateCustomObjectSpaceProviderEventArgs args) {
// ...
args.ObjectSpaceProviders.Add(new NonPersistentObjectSpaceProvider(TypesInfo, null));
}If you now run the application, you will see that the My Non Persistent Object navigation item is created. It opens the List View which is empty, but you can create non-persistent objects with the New Action. If you reopen the List View, all created objects will, obviously, disappear.
You can fill the List View programmatically. Create a Window Controller. In the overridden OnActivated method subscribe to the XafApplication.ListViewCreating event. In the event handler, if the Collection Source's object type is MyNonPersistentObject type, subscribe to the NonPersistentObjectSpace.ObjectsGetting event and populate the e.Objects collection as required.
C#VBusing DevExpress.ExpressApp;
// ...
public class InitializeNonPersistentListViewWindowController : WindowController {
public InitializeNonPersistentListViewWindowController() : base() {
TargetWindowType = WindowType.Main;
}
protected override void OnActivated() {
base.OnActivated();
Application.ListViewCreating += Application_ListViewCreating;
}
private void Application_ListViewCreating(Object sender, ListViewCreatingEventArgs e) {
if ((e.CollectionSource.ObjectTypeInfo.Type == typeof(MyNonPersistentObject)) && (e.CollectionSource.ObjectSpace is NonPersistentObjectSpace)) {
((NonPersistentObjectSpace)e.CollectionSource.ObjectSpace).ObjectsGetting += ObjectSpace_ObjectsGetting;
}
}
private void ObjectSpace_ObjectsGetting(Object sender, ObjectsGettingEventArgs e) {
BindingList<MyNonPersistentObject> objects = new BindingList<MyNonPersistentObject>();
for (int i = 1; i < 10; i++) {
objects.Add(new MyNonPersistentObject() { Name = string.Format("Object {0}", i) });
}
e.Objects = objects;
}
protected override void OnDeactivated() {
base.OnDeactivated();
Application.ListViewCreating -= Application_ListViewCreating;
}
}TipYou can also use the e.Sorting and e.Criteria arguments of the ObjectsGetting event to access sorting and filtering, respectively.
The result is demonstrated in the image below.
The New, Delete and Save Actions are available for non-persistent objects. To access all created, deleted and modified objects within NonPersistentObjectSpace, use the NonPersistentObjectSpace.ModifiedObjects property.
See Also
How to: Display Non-Persistent Objects in a Report
How to: Display a Non-Persistent Object's List View from the Navigation的更多相关文章
- 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 da ...
- Persistent Data Structures
原文链接:http://www.codeproject.com/Articles/9680/Persistent-Data-Structures Introduction When you hear ...
- a different object with the same identifier value was already associat
问题:这个著名的托管态update更新异常 org.hibernate.NonUniqueObjectException: a different object with the same ident ...
- CSS display属性学习
---恢复内容开始--- http://www.w3school.com.cn/cssref/pr_class_display.asp 所有主流浏览器都支持 display 属性,如IE,Firefo ...
- How to: Implement a Custom Base Persistent Class 如何:实现自定义持久化基类
XAF ships with the Business Class Library that contains a number of persistent classes ready for use ...
- How to: Map a Persistent Class to a Database View Which Has No Key Field如何:映射持久化类到无主键数据库视图
With XAF, you can build new applications from scratch or maintain existing databases. The How to: Ge ...
- PeopleSoft Object Types Definitions
PeopleSoft stores object definitions types such as Record, Field and SQL definitions as numbers in ...
- view视图--display中echo出ob_get_contents的缓冲内容--(实现,拼接好文件--导入文件)
view.php01默认设置有3个公共的属性,其他属性.后面实例化的时候.通过传递参数.foreach遍历,不断的增加属性02view对象的实例化.位置在-->控制器父类的构造方法中视图的目录名 ...
- 法线从object space到eye space的转换((normal matrix)
对于顶点来说,从object Space转换到eye space, 使用model-view矩阵就好了.那么顶点的法线是否也可以直接使用model-view矩阵转化? 通常情况下是不行的. 如下两张图 ...
随机推荐
- HDD + HDD(SSD) 多硬盘系统启动问题
一.问题描述 最近购一了款有预留msata接口的hp电脑,买回来开始折腾SSD和内存的问题,内存一次性就解决了:但SSD在安装过程中遇到三个问题,分别是: 无螺丝,无法固定固态硬盘(后在一个旧鼠标上弄 ...
- Python的多线程理解,转自虫师https://www.cnblogs.com/fnng/p/3670789.html
多线程和多进程是什么自行google补脑 对于python 多线程的理解,我花了很长时间,搜索的大部份文章都不够通俗易懂.所以,这里力图用简单的例子,让你对多线程有个初步的认识. 单线程 在好些年前的 ...
- PHP常用符号和函数
(转)最近在写PHP程序的时候发现了一些特殊的PHP符号,例如连续小于符号,三个小于符号,eot,eod,echo示例,print示例等,突然间 发现用这么久的PHP了,竟然连PHP的基本符号都没有认 ...
- DOM、JDOM、DOM4J的区别
dom是解析xml的底层接口之一(另一种是sax) 而jdom和dom4j则是基于底层api的更高级封装 dom是通用的,而jdom和dom4j则是面向Java语言的 DOM 是 ...
- 学习python第五天进制转换
6.进制之间的转换(重要) 二进制:满二进一 范围:0.1符号:0b例如:0b10...[注意]计算机只能识别二进制数据 八进制:满八进一 范围:0~7符号:0o例如:0o66 十进制:满十进一 范围 ...
- IntelliJ IDEA使用技巧一览表
1 .写代码时用 Alt-Insert ( Code|Generate… )可以创建类里面任何字段的 getter 与 setter 方法. 2 .右键点击断点标记(在文本的左边栏里)激活速查菜单,你 ...
- 1927. [SDOI2010]星际竞速【费用流】
Description 10年一度的银河系赛车大赛又要开始了.作为全银河最盛大的活动之一,夺得这个项目的冠军无疑是很多人的 梦想,来自杰森座α星的悠悠也是其中之一.赛车大赛的赛场由N颗行星和M条双向星 ...
- 对于高并发短连接造成Cannot assign requested address解决方法
https://www.cnblogs.com/dadonggg/p/8778318.html 感谢这篇文章给予的启发 在tcp四次挥手断开连接时,主动释放连接的一方最后会进入TIME_WAIT状态, ...
- mapent
package test12; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import ja ...
- java基础 三 概念和java程序的结构.
一.java的一些概念: JRE(java runtime environment):java程序运行环境,如果要运行java程序,需要jre支持.jre里包含jvm JDK(java devel ...