Why the AllowEdit model option "does not work"
The IModelView.AllowEdit property of the ListView model is intended for enabling or disabling grid inline or inplace editing capabilities in the ListView (see List View Edit Modes). This designed behavior is described in the View.AllowEdit Property topic.
The Edit button shown in your screenshot is not related to inline editing, and its visibility is NOT managed by the IModelListView.AllowEdit property.
This button is shown for the ListViewController.EditAction action (see Determine an Action's Controller and Identifier).
How to hide the Edit action
This action's visibility is managed by the ActionBase.Active property. The following topics describe how to change it:
Ways to Change the Active State
How to: Deactivate (Hide) an Action in Code
Here is an example of how to access the ListViewController and change this property manually in code:
C#using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Web.SystemModule;
namespace MainDemo.Module.Web.Controllers {
public class HideEditActionController : ViewController<ListView> {
ListViewController listViewController;
protected override void OnActivated() {
base.OnActivated();
listViewController = Frame.GetController<ListViewController>();
if(listViewController != null) {
listViewController.EditAction.Active["123"] = false;
}
}
protected override void OnDeactivated() {
base.OnDeactivated();
if(listViewController != null) {
listViewController.EditAction.Active.RemoveItem("123");
listViewController = null;
}
}
}
}
Visual BasicImports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Web.SystemModule
Namespace MainDemo.Module.Web.Controllers
Public Class HideEditActionController
Inherits ViewController(Of ListView)
Private listViewController As ListViewController
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
listViewController = Frame.GetController(Of ListViewController)()
If listViewController IsNot Nothing Then
listViewController.EditAction.Active("123") = False
End If
End Sub
Protected Overrides Sub OnDeactivated()
MyBase.OnDeactivated()
If listViewController IsNot Nothing Then
listViewController.EditAction.Active.RemoveItem("123")
listViewController = Nothing
End If
End Sub
End Class
End Namespace
Note that XAF shows another Edit action in Detail Views - WebModificationsController's SwitchToEditMode action.
Can I remove this Edit Action without writing any code?!
Yes, use the HiddenActions node.
How to hide the Edit button only in grid cells
If you want to hide the Edit column completely but still show the Edit action on the toolbar, use the following approach: How to: Hide the Edit Action Column from a ListView in an ASP.NET Application. To conditionally hide the Edit button in certain grid cells only, handle the ActionBase.CustomizeControl event and manage the ASPxGridViewCustomButtonInitializer properties. Alternatively, specify the ActionBase.TargetObjectsCriteria property in code (both approaches are for the ListViewController.EditAction object).
How to prevent opening a record's DetailView
After hiding the Edit action, the user will still be able to show an object's DetailView by clicking on a grid row. To prevent this, use the following solution: How to prevent a DetailView from being shown for a ListView record. You may also want to set the IModelDetailView.AllowEdit property to False in the Model Editor to prevent users from entering a DetailView directly by using a URL.
How to prevent editing records by certain users
The approaches described above can be applied depending on the current user:
Access the Security System in Code
How to: Get the Current User in Code
However, a more reliable solution is to deny Write permissions as described in the Security System Overview topic.
Search keywords
two actions, double Edit button, duplicate Edit buttons, second Edit button, hide inplace Edit, remove column, ListView.AllowEdit, menu, bar, GridViewDataActionColumn