修正,其实只要在基础资料类中加入[XafDefaultProperty("名称")]标签即可。

  1. namespace NEO.ERP.Module.BusinessObjects.Business
  2. {
  3. //引用显示名称
  4. [XafDefaultProperty("名称")]
  5. public partial class 公共基础资料基类
  6. {
  7. public 公共基础资料基类(Session session) : base(session) { }
  8.  
  9. public override void AfterConstruction()
  10. {
  11. base.AfterConstruction();
  12. }
  13.  
  14. }
  15.  
  16. }

下面的是老的引用方法。

在Module项目中如果手工增加的XPO Business Object类,增加了[XafDefaultProperty("名称")]属性后,该对象被别的类调用就可以显示一个下拉列表。

  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. using DevExpress.Xpo;
  5. using DevExpress.ExpressApp;
  6. using System.ComponentModel;
  7. using DevExpress.ExpressApp.DC;
  8. using DevExpress.Data.Filtering;
  9. using DevExpress.Persistent.Base;
  10. using System.Collections.Generic;
  11. using DevExpress.ExpressApp.Model;
  12. using DevExpress.Persistent.BaseImpl;
  13. using DevExpress.Persistent.Validation;
  14.  
  15. namespace HelloXAF.Module.BusinessObjects
  16. {
  17. [DefaultClassOptions]
  18. //[ImageName("BO_Contact")]
  19. [XafDefaultProperty("名称")]
  20. //[DefaultListViewOptions(MasterDetailMode.ListViewOnly, false, NewItemRowPosition.None)]
  21. //[Persistent("DatabaseTableName")]
  22. // Specify more UI options using a declarative approach (https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument112701).
  23. public class AAA : BaseObject
  24. { // Inherit from a different class to provide a custom primary key, concurrency and deletion behavior, etc. (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument113146.aspx).
  25. public AAA(Session session)
  26. : base(session)
  27. {
  28. }
  29. public override void AfterConstruction()
  30. {
  31. base.AfterConstruction();
  32. // Place your initialization code here (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument112834.aspx).
  33. }
  34. //private string _PersistentProperty;
  35. //[XafDisplayName("My display name"), ToolTip("My hint message")]
  36. //[ModelDefault("EditMask", "(000)-00"), Index(0), VisibleInListView(false)]
  37. //[Persistent("DatabaseColumnName"), RuleRequiredField(DefaultContexts.Save)]
  38. //public string PersistentProperty {
  39. // get { return _PersistentProperty; }
  40. // set { SetPropertyValue("PersistentProperty", ref _PersistentProperty, value); }
  41. //}
  42.  
  43. //[Action(Caption = "My UI Action", ConfirmationMessage = "Are you sure?", ImageName = "Attention", AutoCommit = true)]
  44. //public void ActionMethod() {
  45. // // Trigger a custom business logic for the current record in the UI (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument112619.aspx).
  46. // this.PersistentProperty = "Paid";
  47. //}
  48.  
  49. public string 名称 { get; set; }
  50.  
  51. }
  52. }

AAA 列表显示

汇率体系调用AAA时显示如下。

但是,当我们不是通过代码建BO对象时,而是通过ORMDataModel设计器来创建BO对象的时候。设计器创建的BO对象不是像手工建的BO像,设计器创建的对象不是派生于BaseObject,而是派生于XPObject。当我们给基础资料对象赋[XafDefaultProperty("Code")]属性的时候,发现引用该基础资料的下拉列表显示不出来Code或者Name。

网上搜索找到一篇文章。

https://www.devexpress.com/Support/Center/Question/Details/Q306912

原意是 Only the BaseObject class overrides the ToString method, to process the XafDefaultPropertyAttribute.

需要自己手工再处理Tostring()

找到需要被调用的基础资料类,

  1. using System;
  2. using DevExpress.Xpo;
  3. using DevExpress.Data.Filtering;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using DevExpress.Persistent.Base;
  7. using DevExpress.ExpressApp.DC;
  8. using DevExpress.ExpressApp;
  9.  
  10. namespace HelloXAF.Module.BusinessObjects.ORMDataModel_Base
  11. {
  12. [DefaultClassOptions]
  13. [XafDefaultProperty("编码")]
  14. public partial class 币别
  15. {
  16. public 币别(Session session) : base(session) { }
  17. public override void AfterConstruction() { base.AfterConstruction(); }
  18.  
  19. public override string ToString()
  20. {
  21.  
  22. //if (!isDefaultPropertyAttributeInit)
  23. //{
  24. string defaultPropertyName = string.Empty;
  25. XafDefaultPropertyAttribute xafDefaultPropertyAttribute = XafTypesInfo.Instance.FindTypeInfo(GetType()).FindAttribute<XafDefaultPropertyAttribute>();
  26. if (xafDefaultPropertyAttribute != null)
  27. {
  28. defaultPropertyName = xafDefaultPropertyAttribute.Name;
  29. }
  30. else
  31. {
  32. DefaultPropertyAttribute defaultPropertyAttribute = XafTypesInfo.Instance.FindTypeInfo(GetType()).FindAttribute<DefaultPropertyAttribute>();
  33. if (defaultPropertyAttribute != null)
  34. {
  35. defaultPropertyName = defaultPropertyAttribute.Name;
  36. }
  37. }
  38. if (!string.IsNullOrEmpty(defaultPropertyName))
  39. {
  40. var defaultPropertyMemberInfo = ClassInfo.FindMember(defaultPropertyName);
  41. object obj = defaultPropertyMemberInfo.GetValue(this);
  42. if (obj != null)
  43. {
  44. return obj.ToString();
  45. }
  46. }
  47. //isDefaultPropertyAttributeInit = true;
  48. //}
  49. //if (defaultPropertyMemberInfo != null)
  50. //{
  51. // object obj = defaultPropertyMemberInfo.GetValue(this);
  52. // if (obj != null)
  53. // {
  54. // return obj.ToString();
  55. // }
  56. //}
  57. return base.ToString();
  58. }
  59. }
  60.  
  61. }

这样,设计器添加的基础资料也能显示出来了。

  

XAF ORMDataModel构建的基础资料对象无法被调用显示的解决办法的更多相关文章

  1. 使用NDK r10构建Cocosd-x v3.2时编译和链接错误的解决办法

    如果你使用NDK r10构建Cocos2d-x v3.2,将会遇到所有测试用例编译错误以及Lua测试用例链接错误. 1. 编译错误 错误信息是: 1 2 3 4 5 6 7 8 /Users/ming ...

  2. Post数据到 https异常:基础连接已经关闭: 连接被意外关闭 解决办法

    POST数据到HTTPS站点的时候需要设置ServicePointManager类的ServerCertificateValidationCallback属性,并且在POST到https://pass ...

  3. vue双向数据绑定对于数组和新增对象属性不能监听的解决办法

    出现数组不能按照索引进行跟新的原因是处于性能考虑的,但是整体数组的增加删除是可以监听到的:对于对象新增属性不能监听是因为没有在生成vue实例时候放进watcher收集依赖. 首先我们先来了解vue数据 ...

  4. IntelliJ IDEA的jsp中内置对象方法无法被解析的解决办法

    主要原因是因为缺乏依赖 可以通过添加依赖的方式 导入servlet-api.jar,jsp-api.jar,tomcat-api.jar 这三个jar即可 这三个jar在tomcat的lib目录下有 ...

  5. SQL Server 2008空间数据应用系列四:基础空间对象与函数应用

    原文:SQL Server 2008空间数据应用系列四:基础空间对象与函数应用 友情提示,您阅读本篇博文的先决条件如下: 1.本文示例基于Microsoft SQL Server 2008 R2调测. ...

  6. 构建最基础的Spring项目及所需要的jar包

    1.Spring 框架由6个模块组成 上图是spring4的结构图,不同版本结构略有差异,但模块都是相同的. 2.Core Container 核心容器 容器是Spring的核心部分,Core Con ...

  7. 【Gradle】Gradle构建脚本基础

    Gradle构建脚本基础 Settings文件 在Gradle中,定义了一个设置文件,用于初始化以及工程树的配置.设置文件的默认名为settings.gradle,放在根工程目录下. 设置文件大多数的 ...

  8. K3已被禁用的基础资料如何显示出来

    [基础资料]——[公共资料]——[物料.职员.客户==]——[查看]——[选项]——显示禁用基础资料——确定,就可以看见你所禁用过的基础资料,显示为红色字体! 同类问题example: 金蝶K3 禁用 ...

  9. python基础——获取对象信息

    python基础——获取对象信息 当我们拿到一个对象的引用时,如何知道这个对象是什么类型.有哪些方法呢? 使用type() 首先,我们来判断对象类型,使用type()函数: 基本类型都可以用type( ...

随机推荐

  1. 对于现代开发来说,JavaScript就是一种垃圾语言(转)

    伯乐在线导读:昨天 Reddit/Programming 频道的头条热帖是一篇来自 julik live 博主的技术吐槽文,最初的英文标题是"For modern development J ...

  2. MobileSubstrate

    [MobileSubstrate] Cydia Substrate (formerly called MobileSubstrate) is the de facto framework that a ...

  3. idea maven项目依赖项有红色波浪线

    在maven面板选中所有报错的maven项目,右键选择移除(remove),之后重新添加.

  4. css四可见,部分可见和重叠半透明

    <html> <head> <title>javascript</title> <style type="text/css"& ...

  5. Docker 学习笔记_安装和使用MongoDB

    一.准备 1.宿主机OS:Win10 64 2.虚拟机OS:Ubuntu18.04 3.账号:docker 二.安装 1.搜索MongoDB镜像                            ...

  6. 安装sql server 2008重启失败

    sql server2008安装时提示重启计算机失败怎么办   安装SQL Server 2008时,经常会遇到这样一个问题,软件提示“重启计算机失败”,如果忽略的话,会给后面的安装带来很大的麻烦,这 ...

  7. Requests接口测试(四)

    Python序列化和反序列化 啥是序列化?啥是反序列化?这两个词听起来优点高大上的意思,其实呢不然,很简单的可以理解为: 序列化:将python的数据对象编码转换为json格式的字符串 反序列化:将j ...

  8. Selenium家谱

    自动化测试一词也算是整个测试行业里面比较热门的一个词儿,工资高,前景好,有实力,有态度等等,很多企业的管理者也在不断的扩大自己的队伍和职能,这也是导致自动化测试比较流行的原因之一.但是很多企业做自动化 ...

  9. OpenGL绘图框架(GLFW)

    下载地址:http://www.glfw.org/download.html

  10. Terminologies in MVC: Part 2 (Razor Engine Syntax vs Web Form)

    By Abhishek Jaiswal :) on Mar 21, 2015 In this article we learn about Razor Engine Syntax vs Web For ...