扩展XAF模型信息实现自定义功能
如何隐藏 web listview 的 编辑控制列如下图: 这列怎么让它隐藏?
感谢【少侠】XAF_杨东 提供解答!感谢XAF_小学生整理。

A: 注册自定义接口IModelListViewExtender
增加控制项 .
1、定义一个IModelListViewExtender接口。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace ExpressApp.Extensions.Common
{
public interface IModelWebListViewExtender
{
bool HiddenCommandColumn { get; set; }
}
}
2、到XAF的web工程中注册这个扩展。
using System;
using System.Linq;
using System.Text;
using System.ComponentModel;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.DC;
using System.Collections.Generic;
using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Updating;
using DevExpress.ExpressApp.Model.Core;
using DevExpress.ExpressApp.Model.DomainLogics;
using DevExpress.ExpressApp.Model.NodeGenerators;
using DevExpress.Persistent.BaseImpl;
using ExpressApp.Extensions.Common; namespace 资产管理.Module.Web {
[ToolboxItemFilter("Xaf.Platform.Web")]
// For more typical usage scenarios, be sure to check out https://documentation.devexpress.com/eXpressAppFramework/clsDevExpressExpressAppModuleBasetopic.aspx.
public sealed partial class 资产管理AspNetModule : ModuleBase {
private void Application_CreateCustomModelDifferenceStore(Object sender, CreateCustomModelDifferenceStoreEventArgs e) {
#if !DEBUG
e.Store = new ModelDifferenceDbStore((XafApplication)sender, typeof(ModelDifference), true, "Web");
e.Handled = true;
#endif
}
private void Application_CreateCustomUserModelDifferenceStore(Object sender, CreateCustomModelDifferenceStoreEventArgs e) {
e.Store = new ModelDifferenceDbStore((XafApplication)sender, typeof(ModelDifference), false, "Web");
e.Handled = true;
}
public 资产管理AspNetModule() {
InitializeComponent();
}
public override IEnumerable<ModuleUpdater> GetModuleUpdaters(IObjectSpace objectSpace, Version versionFromDB) {
return ModuleUpdater.EmptyModuleUpdaters;
}
public override void Setup(XafApplication application) {
base.Setup(application);
application.CreateCustomModelDifferenceStore += Application_CreateCustomModelDifferenceStore;
application.CreateCustomUserModelDifferenceStore += Application_CreateCustomUserModelDifferenceStore;
// Manage various aspects of the application UI and behavior at the module level.
}
//增加这个方法:
public override void ExtendModelInterfaces(ModelInterfaceExtenders extenders)
{
extenders.Add<IModelListView, IModelWebListViewExtender>();
base.ExtendModelInterfaces(extenders);
}
}
}
3、打开web的xafml,配置

4、写一个Controller来处理这些配置项目
GridViewCommandColumn 即选择操作的列
using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Web.Editors.ASPx;
using DevExpress.Web; namespace ExpressApp.Extensions.Common.Web.Controllers
{
public partial class ListViewExtenderController : ViewController
{
public ListViewExtenderController()
{
InitializeComponent();
RegisterActions(components); TargetViewType = ViewType.ListView;
} protected override void OnDeactivated()
{
ListView view = (ListView)View;
if (view.Editor == null || !(view.Editor is ASPxGridListEditor) || ((ASPxGridListEditor)view.Editor).Control == null ||
!(((ASPxGridListEditor)view.Editor).Control is ASPxGridView) || view.Model == null || !(view.Model is IModelWebListViewExtender))
return; ASPxGridView gridView = (ASPxGridView)view.Editor.Control;
gridView.Load -= AdjustGridView; base.OnDeactivated();
} void AdjustGridView(object sender, EventArgs e)
{
ListView view = (ListView)View;
if (view.Editor == null || !(view.Editor is ASPxGridListEditor) || ((ASPxGridListEditor)view.Editor).Control == null ||
!(((ASPxGridListEditor)view.Editor).Control is ASPxGridView) || view.Model == null || !(view.Model is IModelWebListViewExtender))
return; ASPxGridView gridView = (ASPxGridView)view.Editor.Control;
IModelWebListViewExtender viewExtender = (IModelWebListViewExtender)view.Model; foreach (GridViewColumn c in gridView.Columns)
{
if (c is GridViewCommandColumn)
{ c.Visible = !viewExtender.HiddenCommandColumn;
} }
} protected override void OnViewControlsCreated()
{
base.OnViewControlsCreated(); ListView view = (ListView)View;
if (view.Editor == null || !(view.Editor is ASPxGridListEditor) || ((ASPxGridListEditor)view.Editor).Control == null ||
!(((ASPxGridListEditor)view.Editor).Control is ASPxGridView) || view.Model == null || !(view.Model is IModelWebListViewExtender))
return; ASPxGridView gridView = (ASPxGridView)view.Editor.Control;
gridView.Load += AdjustGridView;
}
}
}
完成
扩展XAF模型信息实现自定义功能的更多相关文章
- python Django教程 之 模型(数据库)、自定义Field、数据表更改、QuerySet API
python Django教程 之 模型(数据库).自定义Field.数据表更改.QuerySet API 一.Django 模型(数据库) Django 模型是与数据库相关的,与数据库相关的代码 ...
- 《Programming WPF》翻译 第9章 3.自定义功能
原文:<Programming WPF>翻译 第9章 3.自定义功能 一旦你挑选好一个基类,你将要为你的控件设计一个API.大部分WPF元素提供属性暴露了多数功能,事件,命令,因为他们从框 ...
- 【翻译】Tusdotnet中文文档(3)自定义功能和相关技术
自定义功能和相关技术 本篇按照如下结构翻译 自定义功能 自定义数据仓库 相关技术 架构和总体概念 自定义数据仓库 tusdotnet附带一个存储库TusDiskStore,它将文件保存在磁盘上的一个目 ...
- 修改jumpserver源码并且实现一个自定义功能模块
在前面已经说了,如何打开jumpserver的管理控制台并且自定义自己的数据模型.接下来实现一个自定义的功能模块. 先看效果! 一 定义好自己的模型(model) 1.1 这一块儿在前一篇博文已经讲过 ...
- Entity Framework 6 Recipes 2nd Edition(10-5)译 -> 在存储模型中使用自定义函数
10-5. 在存储模型中使用自定义函数 问题 想在模型中使用自定义函数,而不是存储过程. 解决方案 假设我们数据库里有成员(members)和他们已经发送的信息(messages) 关系数据表,如Fi ...
- 系统右键自定义功能-右键备份【C#】
平时在某些公司发布网站的时候,都是手动备份文件,以免发布错误,做回滚使用.频繁的发布,在做备份的时候也会稍稍浪费点时间.当然在一些大的公司都会有一些自动发布系统,就不会出现这种问题了,对这种问题,我做 ...
- Qt之模型/视图(自定义进度条)
简述 在之前的章节中分享过关于QHeaderView表头排序.添加复选框等内容,相信大家模型/视图.自定义风格有了一定的了解,下面我们来分享一个更常用的内容-自定义进度条. 实现方式: 从QAbstr ...
- Yii创建前台和后台登录表单和通过扩展 CWebUser 增加信息到 Yii::app()->user
我参考了这篇文章来构建项目的前台和后台的目录结构.感谢Andy的这篇文章.按照所有的步骤,您将有单独的前台和后台面板,如: http://localhost/index.php // 前台 http: ...
- asp.net mvc3 数据验证(二)——错误信息的自定义及其本地化
原文:asp.net mvc3 数据验证(二)--错误信息的自定义及其本地化 一.自定义错误信息 在上一篇文章中所做的验证,在界面上提示的信息都是系统自带的,有些读起来比较生硬.比如: ...
随机推荐
- logback使用总结
filter: http://aub.iteye.com/blog/1110008 http://aub.iteye.com/blog/1101222 Logback Log4j的创始人Ceki Gü ...
- 推荐《HeadFirst设计模式》
相对于国内初版的<大话设计模式>,HeadFirst真的是更好的选择,虽然看起来很厚.很吓人,但对于初学者而言浅显易懂.直击要点,即使对设计模式熟悉的同学去读这本书相信也有很大的收获.用了 ...
- String类中一些的方法的应用
一.整理string类 1.Length():获取字串长度: 2.charAt():获取指定位置的字符: 3.getChars():获取从指定位置起的子串复制到字符数组中:(它有四个参数) 4.rep ...
- PHP 多维数组 Key Value的使用
<?php $user["60"] = array("id" => "60", "num" => &q ...
- The Python Tutorial
1. >>> print('C:\some\name') # here \n means newline! C:\some ame >>> print(r'C:\s ...
- JMeter学习-019-JMeter 监听器之【聚合报告】界面字段解析及计算方法概要说明
聚合报告是 JMeter 使用过程中使用率非常高的监听器之一,可通过右键单击,依次选择[添加 / 监听器 / 聚合报告] 来进行添加.执行 JMeter 脚本后,聚合报告显示如下:
- iScroll.js几个问题及其解决办法
1.在一个页面中需要点击tab切换,而且每个切换的内容都需要下拉刷新加载,这个时候需要在点击的时候用到myScroll.refresh();这个函数,刷新iScroll.js这个函数. 2.在页面中有 ...
- Git branch 和 Git checkout常见用法
git branch 和 git checkout经常在一起使用,所以在此将它们合在一起 1.Git branch 一般用于分支的操作,比如创建分支,查看分支等等, 1.1 git branch 不带 ...
- java求素数和求一个数的一个正整数的质因数
1.题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第四个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少对? (1)程序分析:不难发现兔子的规律是:1,1 ...
- lua 环境揭秘
什么是环境? http://www.lua.org/manual/5.1/manual.html#2.9 Besides metatables, objects of types thread, fu ...