I have an ASPxLookupPropertyEditor with the new button… I need to disable it.
I can hide it but not disable it, could you help me ?
end result should be a dimmed New action on all my lk up controls on a DetailView
this is what I have:
protected override void OnViewControlsCreated()
{
base.OnViewControlsCreated();
foreach (var item in View.Items)
{
if (item is ASPxLookupPropertyEditor)
{
var fld = item as ASPxLookupPropertyEditor;
fld.DropDownEdit.NewButton.ClientVisible = false; //<=====HERE, how to disable and show it.
}
}
}
Thanks for the help.
Hello Raumnz,
you could write a Controller for that…
public abstract partial class DeactivateNewActionInLookupsController : ViewController { public DeactivateNewActionInLookupsController() { InitializeComponent(); RegisterActions(components); TargetViewType = ViewType.ListView; } protected abstract bool IsLookupTemplate(); protected override void OnFrameAssigned() { base.OnFrameAssigned(); Frame.TemplateChanged += Frame_TemplateChanged; } public virtual void HideNewAction(object sender) { if (IsLookupTemplate()) { bool bActive = false; if (sender is NestedFrame h) { //depending on View and Control you can determine whether the 'new' button should be visible or not if (h.ViewItem.ObjectTypeInfo.FullName == "WPS5.Module.BusinessObjects.WPSGroup") { if (h.ViewItem.Id == "Baugruppe") { bActive = true; } } var controller = Frame.GetController<NewObjectViewController>(); controller.NewObjectAction.Active.SetItemValue("LookupListView", bActive); } } private void Frame_TemplateChanged(object sender, EventArgs e) { HideNewAction(sender); } protected override void OnDeactivated() { base.OnDeactivated(); Frame.TemplateChanged -= Frame_TemplateChanged; } }
This controller is abstract because the
IsLookupTemplate() function is platform dependent. So you need also platform dependent controllers, which implement this function.
WINDOWS:
protected override bool IsLookupTemplate() { return Frame.Template is ILookupPopupFrameTemplate; }
WEB:
protected override bool IsLookupTemplate() { var page = Frame.Template as BaseXafPage; if (page != null) return page.TemplateContent is ILookupPopupFrameTemplate; return false; }
Yours
Thomas