In this example it is demonstrated how to show a custom View against a role of the currently logged user. The custom views were created and customized in the Model Editor for each role separately. For more convenience, the custom views have the name of the role in the Id attribute. For instance: Person_ListView_Administrators, Person_DetailView_Administrators, Person_ListView_Guests, Person_DetailView_Guests, etc. You may consider a specific naming convention, for example, to add a role name to the end of the view name.
There is also a controller that tracks showing views in the application and replaces the default view model with a custom view model found in the application model by the role name.
Alternatively, you can handle XafApplication.UserSettingsLoaded event and patch the ViewID attribute of required navigation items under the NavigationItems node as well as the DefaultListView/DefaultDetailView attributes of the BOModel | Class nodes.
Question Comments
Added By: Serkan Dede 1 at: 1/14/2016 10:27:35 AM
Hi,
I got error in Application_ViewShowing method on line :
e.View.SetModel(modelView);
Error Message:
Cannot change property 'DefaultSorting' when the XPCollection is not in design or initialization mode.
Any idea to resolve this issue?
Added By: Dennis (DevExpress Support) at: 1/15/2016 2:02:00 AMHello Serkan,
To process your recent post more efficiently, I created a separate ticket on your behalf: T334575: The "Cannot change property 'DefaultSorting' when the XPCollection is not in design or initialization mode" error occurs when calling e.View.SetModel(modelView);. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
Hello Joel ,
I've created a separate ticket on your behalf (T370594: E274 in 15.2). It has been placed in our processing queue and will be answered shortly.