How to hide the Edit control column for a web listview such as: How does this column make it hidden? Thanks to "little man" Xaf_ Yang Dong to provide answers! Thanks to Xaf_ Elementary School finishing.
A: Register the Custom interface Imodellistviewextender add control.1, define a Imodellistviewextender interface.
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace expressapp.extensions.common{ publicinterface Imodelweblistviewextender { boolgetset;}} }
2. Register this extension in the Web project of XAF.
usingSystem;usingSystem.Linq;usingSystem.Text;usingSystem.ComponentModel;usingDevexpress.expressapp;usingDevExpress.ExpressApp.DC;usingSystem.Collections.Generic;usingDevExpress.ExpressApp.Model;usingDevExpress.ExpressApp.Editors;usingDevExpress.ExpressApp.Actions;usingDevExpress.ExpressApp.Updating;usingDevExpress.ExpressApp.Model.Core;usingDevExpress.ExpressApp.Model.DomainLogics;usingDevExpress.ExpressApp.Model.NodeGenerators;usingDevExpress.Persistent.BaseImpl;usingExpressApp.Extensions.Common;namespaceAsset Management. module.web {[ToolboxItemFilter ("Xaf.Platform.Web")] //for more typical usage scenarios, is sure to check outhttps://documentation.devexpress.com/eXpressAppFramework/clsDevExpressExpressAppModuleBasetopic.aspx. Public Sealed Partial classAsset Management Aspnetmodule:modulebase {Private voidApplication_createcustommodeldifferencestore (Object sender, Createcustommodeldifferencestoreeventargs e) {#if! DEBUGE.store=NewModeldifferencedbstore (xafapplication) sender,typeof(Modeldifference),true,"Web"); E.handled=true; #endif } Private voidApplication_createcustomusermodeldifferencestore (Object sender, Createcustommodeldifferencestoreeventargs e) { E.store=NewModeldifferencedbstore (xafapplication) sender,typeof(Modeldifference),false,"Web"); E.handled=true; } PublicAsset Management Aspnetmodule () {InitializeComponent (); } Public OverrideIenumerable<moduleupdater>getmoduleupdaters (iobjectspace objectspace, Version versionfromdb) {returnmoduleupdater.emptymoduleupdaters; } Public Override voidSetup (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.}//Add this method: Public Override voidextendmodelinterfaces (modelinterfaceextenders extenders) {extenders. ADD<imodellistview, imodelweblistviewextender>(); Base. Extendmodelinterfaces (extenders); } }}
3, open the Xafml of the Web, configure
4. Write a controller to handle these configuration items
Gridviewcommandcolumn The column that selects the action
usingSystem;usingDevexpress.expressapp;usingDevExpress.ExpressApp.Web.Editors.ASPx;usingDevexpress.web;namespaceexpressapp.extensions.common.web.controllers{ Public Partial classListviewextendercontroller:viewcontroller { PublicListviewextendercontroller () {InitializeComponent (); Registeractions (components); Targetviewtype=Viewtype.listview; } protected Override voidondeactivated () {ListView view=(ListView) View; if(View. Editor = =NULL|| ! (View. Editor isAspxgridlisteditor) | | ((aspxgridlisteditor) view. Editor). Control = =NULL|| ! ((aspxgridlisteditor) view. Editor). Control isAspxgridview) | | View. Model = =NULL|| ! (View. Model isImodelweblistviewextender)) return; Aspxgridview GridView=(Aspxgridview) view. Editor.control; Gridview.load-=Adjustgridview; Base. Ondeactivated (); } voidAdjustgridview (Objectsender, EventArgs e) {ListView View=(ListView) View; if(View. Editor = =NULL|| ! (View. Editor isAspxgridlisteditor) | | ((aspxgridlisteditor) view. Editor). Control = =NULL|| ! ((aspxgridlisteditor) view. Editor). Control isAspxgridview) | | View. Model = =NULL|| ! (View. Model isImodelweblistviewextender)) return; Aspxgridview GridView=(Aspxgridview) view. Editor.control; Imodelweblistviewextender Viewextender=(imodelweblistviewextender) view. Model; foreach(Gridviewcolumn Cinchgridview.columns) {if(c isgridviewcommandcolumn) {c.visible=!viewextender.hiddencommandcolumn; } } } protected Override voidonviewcontrolscreated () {Base. Onviewcontrolscreated (); ListView View=(ListView) View; if(View. Editor = =NULL|| ! (View. Editor isAspxgridlisteditor) | | ((aspxgridlisteditor) view. Editor). Control = =NULL|| ! ((aspxgridlisteditor) view. Editor). Control isAspxgridview) | | View. Model = =NULL|| ! (View. Model isImodelweblistviewextender)) return; Aspxgridview GridView=(Aspxgridview) view. Editor.control; Gridview.load+=Adjustgridview; } }}
Complete
Extending the XAF model information for custom functions