Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to prevent a DetailView from being shown for a ListView record

$
0
0

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  property at the Views node level allows you to control this functionality globally per application via the Model Editor;
 - The ShowDetailView property 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 (we can disable this Action to accomplish our task). For more information, refer to the following help topics:
    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.

Note
We added some optimizations intended to improve the DetailView opening performance. This optimization depends on the default behavior - the ListView item click opens a DetailView. We suggest that you disable this optimization if you suppress DetailView opening to avoid issues. To disable the optimization, add the following code to the App_Start event handler:

DevExpress.ExpressApp.Web.WebApplication.OptimizationSettings.AllowFastProcessListViewRecordActions = false;

 


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.

Question Comments

Added By: John01 at: 12/2/2015 6:18:00 PM    

This is such as useful feature that it should be part of standard XAF.

Added By: Dennis (DevExpress Support) at: 12/2/2015 11:48:15 PM    Thanks for your feedback. Our team will take it into account (S34026).Added By: Peter Kieslinger at: 12/19/2017 10:15:01 AM    Hi Dennis,

I tried this solution in web without success.
How can this be done in web?

My current Xaf version is 17.2.3
Added By: Michael (DevExpress Support) at: 12/20/2017 6:02:40 AM    @Peter: I just tested the Web part of this example with the current version of our libraries (17.2.4) and can confirm that the solution works as expected. If you have difficulty implementing it in your project, please submit a new ticket and attach the project demonstrating your attempts.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>