zoukankan      html  css  js  c++  java
  • XAF-如何修改内置的编辑器(Property Editor)

    本示例演示在web/win中给 日期选择控制显示出一个时钟及修改时间的控件。效果如下:

    如果你装了XAF在这个路径中已经有了这个示例:

    %PUBLIC%DocumentsDevExpress Demos 16.2ComponentseXpressApp FrameworkFeatureCenter.

    在线也有一个版本: http://demos.devexpress.com/XAF/FeatureCenter/.

    一、继承属性编辑器
     ASP.NET 模块项目,建个新类出来,继承ASPxDateTimePropertyEditor 
    using System;
    using System.Web.UI.WebControls;
    using DevExpress.Web;
    using DevExpress.ExpressApp.Model;
    using DevExpress.ExpressApp.Editors;
    using DevExpress.ExpressApp.Web.Editors.ASPx;
    //... 
    [PropertyEditor(typeof(DateTime), false)]
    public class CustomDateTimeEditor : ASPxDateTimePropertyEditor {
        public CustomDateTimeEditor(Type objectType, IModelMemberViewItem info) : 
            base(objectType, info) { }
        protected override void SetupControl(WebControl control) {
            base.SetupControl(control);
            if(ViewEditMode == ViewEditMode.Edit) {
                ASPxDateEdit dateEdit = (ASPxDateEdit)control;
                dateEdit.TimeSectionProperties.Visible = true;
                dateEdit.UseMaskBehavior = true;
            }
        }
    }

    如果是win项目:

    using DevExpress.Utils;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.ExpressApp.Editors;
    using DevExpress.ExpressApp.Model;
    using DevExpress.ExpressApp.Win.Editors;
    //... 
    [PropertyEditor(typeof(DateTime), false)]
    public class CustomDateTimeEditor : DatePropertyEditor {
        public CustomDateTimeEditor(Type objectType, IModelMemberViewItem info) : 
            base(objectType, info) { }
        protected override void SetupRepositoryItem(RepositoryItem item) {
            base.SetupRepositoryItem(item);
            RepositoryItemDateTimeEdit dateProperties = (RepositoryItemDateTimeEdit)item;
            dateProperties.CalendarTimeEditing = DefaultBoolean.True;
            dateProperties.CalendarView = CalendarView.Vista;
        }
    }

    二、应用这个编辑器

    上面的代码写完了,编译一下,重新打开xafml.

    找到bo,找到日期型属性,在PropertyEditor中找到CustomDateTimeEditor.

    在xafml中设置日期属性的displayformat和editmask

    或直接在bo中设置。

    using DevExpress.ExpressApp.Model;
    //... 
    [ModelDefault("DisplayFormat", "{0:MM.dd.yyyy hh:mm:ss}")]
    [ModelDefault("EditMask", "MM.dd.yyyy hh:mm:ss")]
    public DateTime CreatedOn { get; set;}

    运行项目,去看结果吧!

    win的效果如下:
  • 相关阅读:
    【YBTOJ】【Luogu P4398】[JSOI2008]Blue Mary的战役地图
    【YBTOJ】【Luogu P2601】[ZJOI2009]对称的正方形
    Hystrix超时设置无效及解决原因
    nginx的压缩
    使用nginx配置本地yum 源
    通过nginx制作类似阿里云镜像下载的网站
    nginx下配置显示网站图标
    nginx---自定义日志格式和json日志
    git clone error: RPC failed; result=35, HTTP code = 0 fatal: The remote end hung up unexpectedly
    nginx---缓存
  • 原文地址:https://www.cnblogs.com/foreachlife/p/custompropertyeditor.html
Copyright © 2011-2022 走看看