Ticket T615246
Visible to All Users

conditionally lookupview new button disable

created 7 years ago

screen shot attached

how can I disable new lookup view button (red circled marked) while debit amount is 0.00 (green circle marked)

additionally on click on new button debit amount should be carried/mapped to new create screen field debit amount

Answers approved by DevExpress Support

created 7 years ago

Hello Harvinder,

To hide the New button in this editor, create a controller for its lookup ListView and deactivate the New action in it. Here is an example of how to access the master object from this controller:

C#
using System; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Web.Editors.ASPx; using MainDemo.Module.BusinessObjects; using DevExpress.ExpressApp.SystemModule; namespace MainDemo.Module.Web { public class WebViewController1 : ObjectViewController<ListView, Position> { protected override void OnActivated() { base.OnActivated(); if (Frame.Context == TemplateContext.LookupControl && Frame is NestedFrame) { ASPxLookupPropertyEditor lookupPropertyEditor = ((NestedFrame)Frame).ViewItem as ASPxLookupPropertyEditor; if (lookupPropertyEditor != null && lookupPropertyEditor.Model.ParentView.Id == "Department_Contacts_ListView") { UpdateNewActionVisibility(lookupPropertyEditor); lookupPropertyEditor.CurrentObjectChanged += lookupPropertyEditor_CurrentObjectChanged; } } } void lookupPropertyEditor_CurrentObjectChanged(object sender, EventArgs e) { UpdateNewActionVisibility((ASPxLookupPropertyEditor)sender); } private void UpdateNewActionVisibility(ASPxLookupPropertyEditor lookupPropertyEditor) { Contact currentContact = lookupPropertyEditor.CurrentObject as Contact; bool addingEnabled = true; if (currentContact != null && currentContact.Department.Title == "SEO") { addingEnabled = false; } Frame.GetController<NewObjectViewController>().NewObjectAction.Active["WebViewController1"] = addingEnabled; } } }

To initialize the new object created by the New button, handle the NewObjectViewController.ObjectCreated event and access the master object in the same manner. See more information in the How to: Initialize an Object Created Using the New Action topic.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.