开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 13921|回复: 0

XAF ORMDataModel构建的基础资料对象无法被调用显示的解决办法

[复制链接]

0

精华

17

贡献

10

赞扬

帖子
32
软币
197
在线时间
20 小时
注册时间
2014-7-3
发表于 2016-10-13 16:14:06 | 显示全部楼层 |阅读模式
在Module项目中如果手工增加的XPO Business Object类,增加了[XafDefaultProperty("名称")]属性后,该对象被别的类调用就可以显示一个下拉列表。
[C#] 纯文本查看 复制代码
using System;
using System.Linq;
using System.Text;
using DevExpress.Xpo;
using DevExpress.ExpressApp;
using System.ComponentModel;
using DevExpress.ExpressApp.DC;
using DevExpress.Data.Filtering;
using DevExpress.Persistent.Base;
using System.Collections.Generic;
using DevExpress.ExpressApp.Model;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;

namespace HelloXAF.Module.BusinessObjects
{
    [DefaultClassOptions]
    //[ImageName("BO_Contact")]
    [XafDefaultProperty("名称")]
    //[DefaultListViewOptions(MasterDetailMode.ListViewOnly, false, NewItemRowPosition.None)]
    //[Persistent("DatabaseTableName")]
    // Specify more UI options using a declarative approach (https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument112701).
    public class AAA : BaseObject
    { // Inherit from a different class to provide a custom primary key, concurrency and deletion behavior, etc. (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument113146.aspx).
        public AAA(Session session)
            : base(session)
        {
        }
        public override void AfterConstruction()
        {
            base.AfterConstruction();
            // Place your initialization code here (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument112834.aspx).
        }
        //private string _PersistentProperty;
        //[XafDisplayName("My display name"), ToolTip("My hint message")]
        //[ModelDefault("EditMask", "(000)-00"), Index(0), VisibleInListView(false)]
        //[Persistent("DatabaseColumnName"), RuleRequiredField(DefaultContexts.Save)]
        //public string PersistentProperty {
        //    get { return _PersistentProperty; }
        //    set { SetPropertyValue("PersistentProperty", ref _PersistentProperty, value); }
        //}

        //[Action(Caption = "My UI Action", ConfirmationMessage = "Are you sure?", ImageName = "Attention", AutoCommit = true)]
        //public void ActionMethod() {
        //    // Trigger a custom business logic for the current record in the UI (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument112619.aspx).
        //    this.PersistentProperty = "Paid";
        //}

        public string 名称 { get; set; }

    }
}

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()
找到需要被调用的基础资料类,
View Code
这样,设计器添加的基础资料也能显示出来了。


评分

参与人数 3贡献 +4 赞扬 +3 收起 理由
士大夫手动 + 1 赞一个
psober + 1 感谢分享
羽叶 + 4 + 1 感谢分享

查看全部评分

回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-4-20 14:09

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表