Scenario
For certain data forms, a developer needs to limit end-users to editing only through the ListView, i.e. without invoking a separate DetailView. This is usually done by activating the inline editing and MasterDetailMode = ListViewAndDetailView features as described at eXpressApp Framework > Concepts > UI Construction > Views > List View Edit Modes. More real user scenarios are described in this Support Center thread.
For more convenience and flexibility, the following Model Editor extensions are implemented in the example to control this behavior:
- The DefaultShowDetailViewFromListView attribute at the Views node level allows you to control this functionality globally per application via the Model Editor;
- The ShowDetailView attribute at the Views | ListView node level allows you to customize only certain List Views via the Model Editor;
Steps to implement
1. Copy the WinWebSolution.Module\ShowDetailViewFromListViewController.xx file into the YourSolutionName.Module project and rebuild it.
The process of opening a DetailView by double clicking/pressing the Enter key on a record selected in a ListView is managed by the standard DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController class and its ProcessCurrentObjectAction. Disabling this action turns off this functionality. For more information, refer to the following help topics:
eXpressApp Framework > Concepts > Application Model > Extend and Customize the Application Model in Code
eXpressApp Framework > Concepts > Application Model > Access the Application Model in Code
ActionBase.Enabled Property
2. For testing purposes, invoke the Model Editor and set the DefaultShowDetailViewFromListView or ShowDetailView properties for the Views or Views | YourObjetType_ListView nodes to False and run the test app to see that a required ListView no longer opens a DetailView in the aforementioned scenario.
ASP.NET
By default, XAF Web uses a special fast callback handler for processing ListView records. This handler is intended to optimize performance of showing a DetailView from a ListView. If a DetailView is not shown on a row click, some UI elements may be refreshed incorrectly. So, we recommend disabling this optimization when this solution is used. To do this globally, add the following code to the App_Start event handler:
[C#]
DevExpress.ExpressApp.Web.WebApplication.OptimizationSettings.AllowFastProcessListViewRecordActions = false;
[VB]
DevExpress.ExpressApp.Web.WebApplication.OptimizationSettings.AllowFastProcessListViewRecordActions = False
To disable this optimization in a particular ListView, deactivate the ListViewFastCallbackHandlerController. See an example in the Faster rendering and other performance optimizations for popular Web UI scenarios in XAF v16.1 article.
IMPORTANT NOTES
This article covers only the case when a DetailView is shown from the ListView after a User double clicks/presses the enter key on a record. Other scenarios should be handled separately by extending the code of this controller. For example, if you do not want to show a DetailView after a new object is created via the New Action, you can handle the NewObjectViewController.ObjectCreating event and set its ObjectCreatingEventArgs.ShowDetailView property to False. However, this is outside the purpose of this article.