2017-04-05 50 views
0

在活动/任务屏幕(cr306020)中,有一个“相关实体”字段,其中包含PXSelector查找以及用于打开相关实体屏幕的铅笔:如何在字段上放置'相关实体'查找

enter image description here

我想知道是否有办法自定义字段做到这一点。我查看了该领域的源代码(它是DAC中的EPActivity.Source),但是我没有看到将这些属性放在该字段中的任何内容。没有PXSelector或类似的东西。

+0

您是否在寻找简单的添加铅笔图标(形式)/超链接(网格列)到一个字段,当点击将您带到另一个页面?看看这篇文章给你你需要什么:http://stackoverflow.com/questions/26387291/how-to-create-a-hyperlink-user-field/34190669#34190669 – Brendan

回答

0

以下示例显示如何在机会(CR304000)屏幕上添加相关实体字段。请注意,本示例中使用的PXRefNoteSelector控件目前不支持Acumatica Customization Manager中的布局编辑器。我用机会来简化和缩短例子。不幸的是,现在只能在自定义屏幕上添加相关实体字段。

现在,让我们向前迈进,样品:

  1. 实现扩展为CROpportunity DAC申报势必UsrRefNoteID和非绑定RelatedEntity领域的数据库。相关实体的NoteID将存储在UsrRefNoteID,和RelatedEntity将用于显示相关实体的用户友好描述:

    public class CROpportunityExt : PXCacheExtension<CROpportunity> 
    { 
        #region UsrRefNoteID 
        public abstract class usrRefNoteID : IBqlField { } 
    
        protected Guid? _UsrRefNoteID; 
    
        [PXDBGuid] 
        [PXParent(typeof(Select<CRActivityStatistics, 
         Where<CRActivityStatistics.noteID, Equal<Current<CROpportunityExt.usrRefNoteID>>>>), LeaveChildren = true)] 
        public Guid? UsrRefNoteID 
        { 
         get 
         { 
          return _UsrRefNoteID; 
         } 
         set 
         { 
          _UsrRefNoteID = value; 
         } 
        } 
        #endregion 
    
        #region Source 
        public abstract class relatedEntity : IBqlField { } 
    
        [PXString(IsUnicode = true)] 
        [PXUIField(DisplayName = "Related Entity Description", Enabled = false)] 
        [PXFormula(typeof(EntityDescription<CROpportunityExt.usrRefNoteID>))] 
        public string RelatedEntity { get; set; } 
        #endregion 
    } 
    
  2. 创建扩展为OpportunityMaint BLC装饰用PXRefNoteSelectorAttribute其主机会数据图。该PXRefNoteSelectorAttribute需要编辑(铅笔)和查找按钮上的自定义相关的实体领域的工作:

    public class OpportunityMaintExt : PXGraphExtension<OpportunityMaint> 
    { 
        [PXCopyPasteHiddenFields(typeof(CROpportunity.resolution))] 
        [PXViewName(Messages.Opportunity)] 
        [PXRefNoteSelector(typeof(CROpportunity), typeof(CROpportunityExt.usrRefNoteID))] 
        public PXSelect<CROpportunity> Opportunity; 
    } 
    
  3. 在ASPX页面,添加PXRefNoteSelector控制与数据字段属性设置为RelatedEntityNoteIDDataFieldUsrRefNoteID。 对于EditButtonLookupButtonLookupPanel标签,使用主数据查看名称饰以PXRefNoteSelector属性(机会在下面的代码段)

    <pxa:PXRefNoteSelector ID="edRefEntity" runat="server" DataField="RelatedEntity" NoteIDDataField="UsrRefNoteID" 
        MaxValue="0" MinValue="0" ValueType="Guid" CommitChanges="true"> 
        <EditButton CommandName="Opportunity$Navigate_ByRefNote" CommandSourceID="ds" /> 
        <LookupButton CommandName="Opportunity$Select_RefNote" CommandSourceID="ds" /> 
        <LookupPanel DataMember="Opportunity$RefNoteView" DataSourceID="ds" TypeDataField="Type" IDDataField="NoteID" /> 
    </pxa:PXRefNoteSelector> 
    
  4. 隐藏通过产生3点的动作表单工具栏中的PXRefNoteSelector属性。用饰有PXRefNoteSelector属性(机会在下面的代码片段)相同的主数据视图的名字在上面步骤:

    <CallbackCommands> 
        ... 
        <px:PXDSCallbackCommand Name="Opportunity$Navigate_ByRefNote" Visible="False" /> 
        <px:PXDSCallbackCommand Name="Opportunity$Select_RefNote" Visible="False" /> 
        <px:PXDSCallbackCommand Name="Opportunity$Attach_RefNote" Visible="False" /> 
    </CallbackCommands> 
    

您可能还需要实现自己的EntityDescription运营商,因为当时这个例子中被创建,它有内部访问修饰符,并没有可用的PX.Objects.dll之外:

public class EntityDescription<RefNoteID> : BqlFormulaEvaluator<RefNoteID>, IBqlOperand 
    where RefNoteID : IBqlField 
{ 
    public override object Evaluate(PXCache cache, object item, Dictionary<Type, object> pars) 
    { 
     Guid? refNoteID = (Guid?)pars[typeof(RefNoteID)]; 
     return new EntityHelper(cache.Graph).GetEntityDescription(refNoteID, item.GetType()); 
    } 
} 

最后...定制机会截图屏采用了全新的相关实体领域:

enter image description here

+0

非常感谢,鲁斯兰 - 我会给它尽快尝试。 – pmfith

相关问题