0
votes

I have created a new table which is a child table for Vendor. Here I want to store some dates for each vendor. Below is the table structure (where CompanyID and RecordID is a PrimaryKey, RecordID is 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]

Based on this I have created a custom project with dataview and added a new tab with grid to display all dates (only 1 column) from the new table. Based on the vendor I browse, these grid should refresh and show me only related data. However, for some reason it is not refreshing and not even showing any data. Below is the screenshot and some code snippet to help understand how I have code in place. May be I am missing something.

enter image description here

Grid code-

<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 snippet-

#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

Dataview and Vendor_RowSelecting event under VendorMaint extension-

[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();
}

Any suggestion.

1

1 Answers

0
votes

Everything looks good besides 2 things:

  1. lack of Enabled property set to True for PXGrid.AutoSize (let me also suggest to change MinHeight to 200, as 1000 is way to much)

    enter image description here

  2. absolutely unnecessary use of RequestRefresh method in RowSelected handler - it must be removed from your BLC extension:

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

On a side note, let me also suggest to replace PXDefault attribute with PXDBDefault on VendorID field within the VendorClosedDates DAC and additionally decorate VendorID with PXParent attribute:

[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 field is mapped to an identity column. Use of the PXDBDefault attribute is required in such cases, otherwise VendorClosedDates.VendorID field won't be updated with new Vendor.BAccountID value generated by database.

  2. PXParentAttribute is required for cascade deletion of VendorClosedDates records when Vendor is deleted from application