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. Linux 环境部署记录(一) - 基础设定

    时间设置 查看系统当前日期/时间: date -R 查看系统硬件时钟: hwclock --show 设置硬件时间: hwclock --set --date="07/18/17 20:55 ...

  2. python---九九乘法表代码

    #_*_ coding:utf-8 _*_# author choco ''' #while循环num1=0while num1<9: num1+=1 num2=1 while num2< ...

  3. linux之安装nali本地解析IP归属

    参考博文:http://www.dwhd.org/20150802_014526.html 1.安装nali wget http://www.dwhd.org/wp-content/uploads/2 ...

  4. 谷歌希望让 Swift 成为安卓的优先选择,以取代由 Oracle 开发的 Java 程序语言。

    http://news.coolban.com/Web/Index/land/app/2/id/405239

  5. C# winform webbrowser如何指定内核为IE11?

    1)假设你应用程序的名字为MyApplication.exe 2)运行Regedit,打开注册表,找到 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsof ...

  6. kubernetes API Server 权限管理实践

    API Server权限控制方式介绍 API Server权限控制分为三种:Authentication(身份认证).Authorization(授权).AdmissionControl(准入控制). ...

  7. mongodb的学习-4-使用 MongoDB shell 来连接 Mongodb 服务

    执行启动操作后,mongodb 在输出一些必要信息后不会输出任何信息,之后就等待连接的建立,当连接被建立后,就会开始打印日志信息. 使用 MongoDB shell 来连接 Mongodb 服务 标准 ...

  8. #leetcode刷题之路45-跳跃游戏 II

    给定一个非负整数数组,你最初位于数组的第一个位置.数组中的每个元素代表你在该位置可以跳跃的最大长度.你的目标是使用最少的跳跃次数到达数组的最后一个位置. 示例:输入: [2,3,1,1,4]输出: 2 ...

  9. Linux学习笔记(第六章)

    第六章-档案权限与目录配置#chgrp:改变档案的所属群组#chown:改变档案的拥有者#chmod:改变档案的权限及属性 chown用法 chmod用法: r:4 w:2 x:1对于文档: 对于目录 ...

  10. MongoDB登录验证及用户管理

    一.超级管理员创建及开启登录验证 如果MongoDB要开启登录验证,必须在开启登录验证之前先创建好超级管理员,否则无法登录数据库! 例如,创建一个超级管理员admin,关联给admin数据库,角色设置 ...