Extending the XAF model information for custom functions

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.