How to: Detect a Lookup List View in Code How to: Find detected in the code list view

This topic demonstrates how to check if the current View is a Lookup List View. This can be useful if you want to customize Lookups only, for instance, to hide the New Action displayed below the Lookup List View.

This topic demonstrates how to check whether the current view is to find the list view. If you want to customize the "look" (for example, to hide the "Find List" "New Action" under the view displays), this feature is useful.

Note Note
Mobile applications do not have a specific template for Lookup List Views and do not support the approach described in this topic.
Mobile application is not used to find the list view specific template, and the method described in this topic is not supported.

Implement a View Controller that targets List Views only and override the OnActivated method. Check that the Frame.Context value is LookupControl or LookupWindow. If the condition is true, this means that the current List View is a Lookup List View.

Implement the view controller is only available to the list view and covers On "activated" method. Check the Frame. Context is to find the control value or the Find window. If the condition is true, the current list view is "to find the list view."

 

You can now, for example, deactivate the New Action in all Lookups. Use the Frame.GetController<ControllerType> method to get the NewObjectViewController and then use the NewObjectViewController.NewObjectAction property to access the New Action.

For example, you can now disable the "new action" in all lookup. Use Frame.GetController <ControllerType> method of obtaining NewObjectView controller, then the controller .NewObjectAction NewObjectView access attribute "New Action."

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.SystemModule;
// ...
public class DeactivateNewActionInLookupsController : ViewController<ListView> {
    protected override void OnActivated() {
        base.OnActivated();
        if (Frame.Context == TemplateContext.LookupControl || Frame.Context == TemplateContext.LookupWindow) {
            NewObjectViewController controller = Frame.GetController<NewObjectViewController>();
            if (controller != null) {
                controller.NewObjectAction.Active.SetItemValue("LookupListView", false);
            }
        }
    }
}

 

Run a WinForms or ASP.NET application to ensure that the New Action is deactivated in all Lookup List Views.

WinForms or ASP.NET applications running, to ensure that disabled the "new operation" in all lookup list view.

 

You can also detect a Lookup List View by its View.Id: all Lookup List Views have identifiers with the "_LookupListView" suffix by default. However, this also detects Views that were initially designed as Lookups, but are not used as Lookups.

You can also find a list view their View.Id detection: By default, all find a list view has with "_LookupListView" suffix identifier. However, this view is also detected as a look but did not find the original design.

Tip Tip
If you want to hide the New Action for a particular Lookup List View, find the corresponding View node in the Model Editor and set the IModelView.AllowNew property to false.

If you want to hide a specific lookup list view of the "New Action", please find the appropriate view nodes in the model editor, and IModelView.AllowNew property is set to false.

Guess you like

Origin www.cnblogs.com/foreachlife/p/How-to-Detect-a-Lookup-List-View-in-Code.html