在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
这样,设计器添加的基础资料也能显示出来了。
|