如何在Acumatica屏幕中有条件地隐藏PXTabItem? [英] How to conditionally hide PXTabItem inside an Acumatica screen?

查看:64
本文介绍了如何在Acumatica屏幕中有条件地隐藏PXTabItem?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想隐藏销售订单行佣金选项卡,但是我只希望隐藏特定角色的选项卡。这可能吗?

I want to HIDE the Sales Order Line Commissions Tab, but I only want the Tab Hidden for a Specific Role. Is this possible?

推荐答案

选项1:使用PXTabItem VisibleExp属性



这种方法在相当简单的声明性条件下完美地工作,该条件利用了来自特定容器的输入控制值(在这种情况下, PXForm 最常用)。

例如,要隐藏 TR 类型的订单的销售订单佣金标签,您应按以下方式撰写 VisibleExp

<px:PXTabItem Text="Commissions"
              VisibleExp="DataControls[&quot;edOrderType&quot;].Value!=TR" 
              BindingContext="form" 
              RepaintOnDemand="false">

上面代码段中使用的3个 PXTabItem 属性的快速概述:

A quick overview of the 3 PXTabItem properties used in the code snippet above:


  • BindingContext :容器控件的ID,该容器控件托管用于计算PXTabItem可见属性的输入控件

  • VisibleExp :用于计算PXTabItem可见属性的表达式

  • RepaintOnDemand :控制以下项的初始化: PXTab控件。设置为True(默认值)时,仅当用户选择Tab时才会初始化PXTabItem,否则,它将在每次回发时初始化。

  • BindingContext: the ID of the container control hosting input controls used to calculate visible property for PXTabItem
  • VisibleExp: the expression to calculate visible property for PXTabItem
  • RepaintOnDemand: controls the initialization of PXTab control. When set to True (the default value) PXTabItem will be initialized only when a user selects the Tab, otherwise, it will initialize with every postback.

毫无疑问,与 PXTabItem相比,此方法在灵活性方面向前迈了一大步VisibleExp 属性。它使您可以在业务逻辑内部编写更复杂的条件,而不必依赖网页。

Without a doubt, this approach is a step forward in terms of flexibility comparing to PXTabItem VisibleExp property. It allows you to compose way more complex conditions inside business logic and do not rely on a webpage.

要隐藏销售订单佣金选项卡,应订阅SOOrder的RowSelected处理程序,如下所示:

To hide the Sales Order Commissions tab, you should subscribe to the RowSelected handler for SOOrder as follows:

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    public void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        SOOrder order = (SOOrder)e.Row;
        if (order == null) return;

        bool financeRoleMember = System.Web.Security.Roles.IsUserInRole("FINANCE");
        Base.SalesPerTran.AllowSelect = financeRoleMember;
        PXUIFieldAttribute.SetVisible<SOOrder.salesPersonID>(Base.Document.Cache, null, financeRoleMember);
    }
}

设置了 AllowSelect 属性设为false时, SalesPerTran 数据视图将自动隐藏每个 PXGrid ,其 DataMember 属性设置为 SalesPerTran > 。由于销售订单佣金选项卡还包含默认销售员查找,因此我们需要为 PXUIFieldAttribute 设置 Visible 属性为 false 。 strong>装饰SOOrder SalesPersonID字段。 PXTabItem 在不包含可见控件时会自动隐藏。

With AllowSelect property set to false, the SalesPerTran data view will automatically hide every PXGrid, whose DataMember property is set to SalesPerTran. Since the Sales Order Commissions tab also contains Default Salesperson lookup, we need to additionally set Visible property to false for the PXUIFieldAttribute decorating SOOrder SalesPersonID field. PXTabItem automatically hides when it contains no visible controls.

请注意,类似于 PXTabItem VisibleExp 属性,在为了使此方法正常运行,您必须始终将 PXTabItem RepaintOnDemand 设置为 false 。对于此特定示例,我们可以跳过此步骤,因为原始 SO301000.aspx 中的 RepaintOnDemand 设置为 false >由Acumatica分发的文件。

Please be advised, similar to PXTabItem VisibleExp property, in order for this approach to function properly, you have to always set RepaintOnDemand to false for the PXTabItem you conditionally hide. For this particular example, we can skip this step, because RepaintOnDemand is set to false in the original SO301000.aspx file distributed by Acumatica.

这篇关于如何在Acumatica屏幕中有条件地隐藏PXTabItem?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆