如何隐藏 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模型信息实现自定义功能的更多相关文章

  1. python Django教程 之 模型(数据库)、自定义Field、数据表更改、QuerySet API

    python  Django教程  之 模型(数据库).自定义Field.数据表更改.QuerySet API 一.Django 模型(数据库) Django 模型是与数据库相关的,与数据库相关的代码 ...

  2. 《Programming WPF》翻译 第9章 3.自定义功能

    原文:<Programming WPF>翻译 第9章 3.自定义功能 一旦你挑选好一个基类,你将要为你的控件设计一个API.大部分WPF元素提供属性暴露了多数功能,事件,命令,因为他们从框 ...

  3. 【翻译】Tusdotnet中文文档(3)自定义功能和相关技术

    自定义功能和相关技术 本篇按照如下结构翻译 自定义功能 自定义数据仓库 相关技术 架构和总体概念 自定义数据仓库 tusdotnet附带一个存储库TusDiskStore,它将文件保存在磁盘上的一个目 ...

  4. 修改jumpserver源码并且实现一个自定义功能模块

    在前面已经说了,如何打开jumpserver的管理控制台并且自定义自己的数据模型.接下来实现一个自定义的功能模块. 先看效果! 一 定义好自己的模型(model) 1.1 这一块儿在前一篇博文已经讲过 ...

  5. Entity Framework 6 Recipes 2nd Edition(10-5)译 -> 在存储模型中使用自定义函数

    10-5. 在存储模型中使用自定义函数 问题 想在模型中使用自定义函数,而不是存储过程. 解决方案 假设我们数据库里有成员(members)和他们已经发送的信息(messages) 关系数据表,如Fi ...

  6. 系统右键自定义功能-右键备份【C#】

    平时在某些公司发布网站的时候,都是手动备份文件,以免发布错误,做回滚使用.频繁的发布,在做备份的时候也会稍稍浪费点时间.当然在一些大的公司都会有一些自动发布系统,就不会出现这种问题了,对这种问题,我做 ...

  7. Qt之模型/视图(自定义进度条)

    简述 在之前的章节中分享过关于QHeaderView表头排序.添加复选框等内容,相信大家模型/视图.自定义风格有了一定的了解,下面我们来分享一个更常用的内容-自定义进度条. 实现方式: 从QAbstr ...

  8. Yii创建前台和后台登录表单和通过扩展 CWebUser 增加信息到 Yii::app()->user

    我参考了这篇文章来构建项目的前台和后台的目录结构.感谢Andy的这篇文章.按照所有的步骤,您将有单独的前台和后台面板,如: http://localhost/index.php // 前台 http: ...

  9. asp.net mvc3 数据验证(二)——错误信息的自定义及其本地化

    原文:asp.net mvc3 数据验证(二)--错误信息的自定义及其本地化 一.自定义错误信息         在上一篇文章中所做的验证,在界面上提示的信息都是系统自带的,有些读起来比较生硬.比如: ...

随机推荐

  1. asp.net identity 2.2.0 中角色启用和基本使用(五)

    建立控制器UsersAdminController 第一步:在controllers文件夹上点右键>添加>控制器, 我这里选的是“MVC5 控制器-空”,名称设置为:UsersAdminC ...

  2. 利用脚本获取mysql的tps,qps等状态信息

    #!/bin/bash mysqladmin -uroot -p'123456' extended-status -i1|awk 'BEGIN{local_switch=0;print "Q ...

  3. centos安装php-memcached扩展及cas用法

    一.安装libmemcachedwget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar ...

  4. INSTRUCTION EXECUTION CHARACTERISTICS

    Characteristics of Some CISCs, RISCs, and Superscalar Processors One of the most visible forms of ev ...

  5. linux 查找命令

    查找目录:find /(查找范围) -name '查找关键字' -type d查找文件:find /(查找范围) -name 查找关键字 -print

  6. eclipse闪退

    svn提交我的项目时,由于网络故障,提交不上去,一直checking.......,然后我强制关闭eclipse后重启,发现启动不了了,一点击,尝试打开的状态就突然没了,试了几次都这样,重启电脑打开还 ...

  7. 不错的开源FTP类库

    socket开源ftp类库代码:http://netftp.codeplex.com/ 需要注意事项,如果以下代码出现乱码问题,可以设置其中的Encoding属性就可以. 用法示例: using Sy ...

  8. Life is hard

    Life is hard, always so.If there's anything to give you a hard life with sunshine and warmth, please ...

  9. 获取Python安装目录

    >>> import sys>>> path=sys.executable>>> print (path)C:\Users\jumz-G\AppD ...

  10. zjuoj 3602 Count the Trees

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3602 Count the Trees Time Limit: 2 Seco ...