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矩阵转化? 通常情况下是不行的. 如下两张图 ...
随机推荐
- 在 vSphere 5.x/6.0 中配置 Network Dump Collector 服务 (2002954)
vmware KB: https://kb.vmware.com/s/article/2002954?lang=zh_CN 重点配置命令: 使用 vSphere Client 连接到 vCenter ...
- 关于 svn
文章:http://www.cnblogs.com/xing901022/p/4403339.html 视频http://www.imooc.com/learn/109 7******* ...
- 如何让邮件营销平台成为EDM神器?
任何一家做邮件营销的企业都希望自己的投入获得超乎想象的回报,出现打开率.点击率和伴随而来的成交量能够节节攀升的现象,这些数据我们当然可以通过监测各种平台的反馈而得到确切的报表.当然,作为邮件营销平台运 ...
- Spring 入门(概述)
1.什么是框架 2.Spring简介 3.IOC(配置.注解) 4.Bean(配置.注解) 5.AOP(配置.注解.AspectJ.API) 资源: http://spring.io/ http:// ...
- PHP设计模式系列 - 建造者模式
什么是建造者模式 建造者模式主要是为了消除其它对象复杂的创建过程. 设计场景 有一个用户的UserInfo类,创建这个类,需要创建用户的姓名,年龄,金钱等信息,才能获得用户具体的信息结果. 创建一个U ...
- 【转载】Java 集合框架
http://wangkuiwu.github.io/2012/02/03/collection-03-arraylist/ 网上比较全的Java集合框架教程. 注:transient是Java语言的 ...
- 20165318 2017-2018-2 《Java程序设计》第四周学习总结
20165318 2017-2018-2 <Java程序设计>第四周学习总结 IDEA安装 按照娄老师Intellj IDEA 简易教程,我下载了IDEA但是由于没有注册学校邮箱,我没办法 ...
- Java并发编程--1.Thread和Runnable
创建线程 Java有两种方式创建线程, 继承Thread类和实现Runnable接口 继承Thread 步骤: 1.自定义一个类继承Thread类, 重写run方法 2.创建自定义类的对象,调用sta ...
- oracle查询指定月份数据
SELECT * FROM [表名] where to_number(to_char([表中日期字段],'mm')) = [要查找的月份]
- bootstrap 多选款样式:bootstrap-switch
有时候,为了美化checkbox后者radio的时候,让用户体验起来更好,jquery里有icheck. bootstrap里有bootstrap-switch,就简单介绍下bootstrap-swi ...