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#
    VB
     
    using DevExpress.ExpressApp.DC;
    using DevExpress.Persistent.Base;
    // ... 
    [DomainComponent, DefaultClassOptions]
    public class MyNonPersistentObject {
    // ... 
    }
    Note

    For simplicity, implementation of the INotifyPropertyChangedIXafEntityObject 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#
    VB
     
    protected 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#
    VB
     
    using 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;
    }
    }
    Tip

    You 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.

Tip

The NewDelete 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 a Non-Persistent Object's List View from the Navigation的更多相关文章

  1. 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 ...

  2. Persistent Data Structures

    原文链接:http://www.codeproject.com/Articles/9680/Persistent-Data-Structures Introduction When you hear ...

  3. a different object with the same identifier value was already associat

    问题:这个著名的托管态update更新异常 org.hibernate.NonUniqueObjectException: a different object with the same ident ...

  4. CSS display属性学习

    ---恢复内容开始--- http://www.w3school.com.cn/cssref/pr_class_display.asp 所有主流浏览器都支持 display 属性,如IE,Firefo ...

  5. 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 ...

  6. 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 ...

  7. PeopleSoft Object Types Definitions

     PeopleSoft stores object definitions types such as Record, Field and SQL definitions as numbers in  ...

  8. view视图--display中echo出ob_get_contents的缓冲内容--(实现,拼接好文件--导入文件)

    view.php01默认设置有3个公共的属性,其他属性.后面实例化的时候.通过传递参数.foreach遍历,不断的增加属性02view对象的实例化.位置在-->控制器父类的构造方法中视图的目录名 ...

  9. 法线从object space到eye space的转换((normal matrix)

    对于顶点来说,从object Space转换到eye space, 使用model-view矩阵就好了.那么顶点的法线是否也可以直接使用model-view矩阵转化? 通常情况下是不行的. 如下两张图 ...

随机推荐

  1. 一、DAO设计模式 二、DAO设计模式的优化 三、JDBC中的事务,连接池的使用

    一.DAO设计模式概述###<1>概念 DAO,Data Access Object ,用于访问数据库的对象. 位于业务逻辑和数据持久化层之间,实现对数据持久化层的访问![](1.png) ...

  2. ubuntu 12.04 eclipse增加桌面快捷方式

    1.创建桌面启动器(编辑/usr/share/applications/eclipse.desktop) [Desktop Entry] Encoding=UTF-8 Name=eclipse Com ...

  3. 数据库学习之中的一个: 在 Oracle sql developer上执行SQL必知必会脚本

    1 首先在開始菜单中打开sql developer: 2. 创建数据库连接 点击左上角的加号 在弹出的对话框中填写username和password 測试假设成功则点击连接,记得角色要写SYSDBA ...

  4. sql排序方法

    SQL Server中使用order by charindex按指定顺序排序 在使用SQL Server数据库编程中,有时需要对取出来的数据按照指定的顺序排序,例如,取出来的数据某个字段值有张三.李四 ...

  5. robotframwork接口测试(五)—接口分层测试粗解

    个人小结,仅供参考. 接口测试很简单,但是很重要. 可以写代码,也可以用工具进行测试.工具说说就很多了,简单介绍一下我目前用过的几个能够测试接口的工具, Burpsuite:这类偏请求攻击类软件 Fi ...

  6. Python自动化之traceback

    import traceback try: 11/a except Exception: b = traceback.format_exc() traceback.format_exc()会存储详细的 ...

  7. python-文件基本操作(一) (转载)

    转载自: https://www.cnblogs.com/nizhihong/p/6528439.html 一.打开文件的方法: 注意:file()和open()基本相同,且最后要用close()关闭 ...

  8. CanOpen协议【CanFestival】移植方法 支持VC、QT、STM32

    前段时间学习了CanOpen协议,到网上下载的CanFestival3-10源码,移植到VC.QT.STM32等平台,由于网上的资源较少,走了不少弯路,移植好使用过程中才逐渐暴露出各种问题,比如OD字 ...

  9. java官网门户源码 SSM框架 自适应-响应式 freemarker 静态模版引擎

    来源:http://www.fhadmin.org/webnewsdetail3.html 前台:支持(5+1[时尚单页风格])六套模版,可以在后台切换 官网:www.fhadmin.org 系统介绍 ...

  10. Java类是如何默认继承Object的?

    原:https://juejin.im/post/5ca1e8ade51d454e6a300048 前言 学过Java的人都知道,Object是所有类的父类.但是你有没有这样的疑问,我并没有写exte ...