【问题标题】:Custom Tab with Grid not refreshing with navigating master data带有网格的自定义选项卡不会在导航主数据时刷新
【发布时间】:2017-02-09 02:39:13
【问题描述】:

我创建了一个新表,它是供应商的子表。在这里,我想为每个供应商存储一些日期。下面是表结构(其中CompanyID和RecordID是PrimaryKey,RecordID是Identity with seed 1)-

CREATE TABLE [dbo].[VendorClosedDates](
	[CompanyID] [int] NOT NULL,
	[RecordID] [int] IDENTITY(1,1) NOT NULL,
	[VendorID] [int] NOT NULL,
	[VendorCloseDate] [datetime] NOT NULL,
	[tstamp] [timestamp] NOT NULL,
	[CreatedByID] [uniqueidentifier] NOT NULL,
	[CreatedByScreenID] [char](8) NOT NULL,
	[CreatedDateTime] [datetime] NOT NULL,
	[LastModifiedByID] [uniqueidentifier] NOT NULL,
	[LastModifiedByScreenID] [char](8) NOT NULL,
	[LastModifiedDateTime] [datetime] NOT NULL,
 CONSTRAINT [PK_VendorClosedDates] PRIMARY KEY CLUSTERED 
(
	[CompanyID] ASC,
	[RecordID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

基于此,我创建了一个带有数据视图的自定义项目,并添加了一个带有网格的新选项卡,以显示新表中的所有日期(仅 1 列)。根据我浏览的供应商,这些网格应该刷新并只显示相关数据。但是,由于某种原因,它没有刷新,甚至没有显示任何数据。下面是屏幕截图和一些代码 sn-p 以帮助理解我是如何编写代码的。可能是我错过了一些东西。

网格代码-

<px:PXTabItem Text="Closed Dates">
<Template>
  <px:PXGrid runat="server" ID="CstPXGrid79" DataSourceID="ds" SkinID="DetailsInTab" Height="150px" Width="100%" AdjustPageSize="Auto" AllowPaging="True">
	<Levels>
	  <px:PXGridLevel DataMember="ClosedDates">
		<Columns>
		  <px:PXGridColumn DataField="VendorCloseDate" Width="90" /></Columns>
		<RowTemplate>
		  <px:PXDateTimeEdit runat="server" ID="CstPXDateTimeEdit82" DataField="VendorCloseDate" /></RowTemplate></px:PXGridLevel></Levels>
	<Mode AllowAddNew="True" AllowDelete="True" AllowUpdate="True" />
	<AutoSize MinHeight="1000" /></px:PXGrid></Template></px:PXTabItem>

DAC sn-p-

#region RecordID
public abstract class recordID : PX.Data.IBqlField
{
}
protected int? _RecordID;
[PXDBIdentity(IsKey = true)]
public virtual int? RecordID
{
	get
	{
		return this._RecordID;
	}
	set
	{
		this._RecordID = value;
	}
}
#endregion
#region VendorID
public abstract class vendorID : PX.Data.IBqlField
{
}
protected int? _VendorID;
[PXDBInt()]
[PXDefault(typeof(Vendor.bAccountID))]
public virtual int? VendorID
{
	get
	{
		return this._VendorID;
	}
	set
	{
		this._VendorID = value;
	}
}
#endregion
#region VendorCloseDate
public abstract class vendorCloseDate : PX.Data.IBqlField
{
}
protected DateTime? _VendorCloseDate;
[PXDBDate()]
[PXUIField(DisplayName = "Vendor Close Date")]
public virtual DateTime? VendorCloseDate
{
	get
	{
		return this._VendorCloseDate;
	}
	set
	{
		this._VendorCloseDate = value;
	}
}
#endregion

VendorMaint扩展下的Dataview和Vendor_RowSelecting事件-

[PXViewName("ClosedDates")]
public PXSelect<VendorClosedDates,
		Where<VendorClosedDates.vendorID, Equal<Current<Vendor.bAccountID>>>> ClosedDates;

protected virtual void Vendor_RowSelecting(PXCache cache, PXRowSelectingEventArgs e)
{
	ClosedDates.View.RequestRefresh();
}

任何建议。

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    除了两件事之外,一切看起来都不错:

    1. PXGrid.AutoSize 缺少 Enabled 属性设置为 True(我还建议将 MinHeight 更改为 200,因为 1000 太多了)

    2. 在 RowSelected 处理程序中绝对不必要地使用 RequestRefresh 方法 - 它必须从您的 BLC 扩展中删除:

      protected virtual void Vendor_RowSelecting(PXCache cache, PXRowSelectingEventArgs e)
      {
          ClosedDates.View.RequestRefresh();
      }
      

    另外,我还建议在 VendorClosedDates DAC 内的 VendorID 字段上用 PXDBDefault 替换 PXDefault 属性,并用 PXParent 属性另外装饰 VendorID:

    [Serializable]
    public class VendorClosedDates : IBqlTable
    {
        ...
    
        #region VendorID
        [PXDBInt()]
        [PXDBDefault(typeof(Vendor.bAccountID))]
        [PXParent(typeof(Select<Vendor, Where<Vendor.bAccountID, Equal<Current<VendorClosedDates.vendorID>>>>))]
        public int? VendorID { get; set; }
    
        public class vendorID : IBqlField { }
        #endregion
    
        ...
    }
    
    1. Vendor.BAccountID 字段映射到标识列。在这种情况下需要使用 PXDBDefault 属性,否则 VendorClosedDates.VendorID 字段将不会被数据库生成的新 Vendor.BAccountID 值更新。

    2. 从应用程序中删除 Vendor 时,级联删除 VendorClosedDates 记录需要 PXParentAttribute

    【讨论】:

    • 感谢工作。不确定 AutoSize > Enable = True 如何分别刷新网格
    • 最初你设置AllowPaging="True"AdjustPageSize="Auto"-来决定PXGrid在一页上可以显示多少行,它必须在Aspx页面上正确排列。该问题已通过将 PXGrid.AutoSize 元素的 Enabled 属性设置为 True 来解决。另请查看先前的答案以获取 2 项额外改进。
    • 谢谢鲁斯兰。
    猜你喜欢
    • 1970-01-01
    • 2011-07-24
    • 1970-01-01
    • 1970-01-01
    • 2013-06-11
    • 1970-01-01
    • 2011-07-01
    • 1970-01-01
    • 2011-03-25
    相关资源
    最近更新 更多