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矩阵转化? 通常情况下是不行的. 如下两张图 ...
随机推荐
- 摄像机内参相关(3ds max)
一般的原理参考:http://ksimek.github.io/2012/08/13/introduction/ 对于3ds max建模时使用的target camera,如果想得到它的内外参,可以利 ...
- for 与forEach的区别
for循环 for循环,通过下标,对循环中的代码反复执行,功能强大,可以通过index取得元素.在处理比较复杂的处理的时候较为方便. foreach循环 foreach,从头到尾,对于集合中的对象遍历 ...
- 转贴:C语言链表基本操作
http://www.oschina.net/code/snippet_252667_27314#comments 这个代码有很多错误,估计是从老谭书上抄来但是很多还抄错了:对照老谭的书好好研究下.切 ...
- SPH算法(求最小代价树)
一.sph算法简介 1.最小代价树算法 SPH算法也叫做MPH( minimum path heuristic)算法, 用于构造时延约束最算法小代价组播树. 该算法中每 个目的结点通过与当前组播树有最 ...
- 关于for...in和for...of的思考
关于for...in和for...of的思考 在编写js代码的时候,我们经常性的要对数据集合进行遍历,Array.Object.以及ES6新属性Map.Set,甚至String类型都是可遍历的. 我们 ...
- QT导入libcurl支持HTTPS
对于我这种不会编译的人来说,必须找到已经编译好的DLL文件,以及头文件才能使用. 幸运的在这个网站https://stackoverflow.com/questions/28137379/libcur ...
- 如何运行vue项目(从gethub上download的开源项目)
前提:入坑vue.js,从GitHub上download一个vue.js的开源项目,发现不知如何在浏览器运行,通过查阅网上教程,发现网上的很多是教你怎么新建项目,并没有一个是教如何打开已有的项目.自已 ...
- BZOJ1001: [BeiJing2006]狼抓兔子【最短路+对偶图】
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1001 1001: [BeiJing2006]狼抓兔子 Time Limit: 15 Se ...
- HTML头标签使用-又一次定向,refresh
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- 3226. [SDOI2008]校门外的区间【线段树】
Description 受校门外的树这道经典问题的启发,A君根据基本的离散数学的知识,抽象出5种运算维护集合S(S初始为空)并最终输出S.现在,请你完成这道校门外的树之难度增强版——校门外的区间. ...