如何隐藏 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. jquery选择伪元素属性的方法

    CSS伪元素不是DOM元素,因此你无法直接选择到它们 一个方法是为该元素添加新类,并通过设置新类的属性来达到改变伪元素属性的效果: .checkboxWrapper.selected::before{ ...

  2. C#记录程序耗时的方法

    用于准确测量运行时间的方法类: System.Diagnostics.Stopwatch 具体使用方法: using System.Diagnostics; Stopwatch stopwatch = ...

  3. do put in ruby

    apikey: XO.apikeys.cms, data: { favoriteItems: [{ UserId: SaveToFavoriteVar.content.FavoriteItem.Use ...

  4. jquery 图片本地预览

    uploadPreview.js /* *名称:图片上传本地预览插件 v1.1 *介绍:基于JQUERY扩展,图片上传预览插件 目前兼容浏览器(IE 谷歌 火狐) 不支持safari *参数说明: I ...

  5. sql 时间差

    select * from Tickets where ( case when UnloadTime is null then datediff(hh,LoadTime,getdate()) else ...

  6. javascript jsscript .js xml html json soap

    javascript ecma标准的脚本语言用于 jsscript 微软标准的一种脚本语言 .js javascript或jsscript保存成文件的形式可用于在html里重复引用 jsscript只 ...

  7. ZoomBar 设计

    package com.example.canvasdemo; import android.content.Context; import android.graphics.Canvas; impo ...

  8. 使用compass自动合并css雪碧图(css sprite)

    本文转载自: 使用compass自动合并css雪碧图(css sprite)

  9. SQL内联多个表

    SQL多个表组合成一个表: strSql.Append(@"Select N.NotificationOptionId, S.FullName, No.Title, N.SortCode, ...

  10. 【数论】Miller_Rabin

    Miller_Rabin素数测试     Miller_Rabin判断单个素数的方法运用了费马小定理,可以说非常之快了.     Miller_Rabin曾经被称作“黑科技”,但是根据费马小定理其实完 ...