I have created a new “FormTab.master” form that I have two problems with it. The form works fine when I take away the tab from the form but when add it back the problems persist.
- When I Click Add New Record, not sure the form doesn’t reset the fields. The fields whithout default value, should be empty but are not.
- Even if the data is saved (I confirmed through both DB and Primary List) after clicking on Save, no matther what action I trigger (Add New, First, Last ...) I get an error that "Any unsaved changes will be discarded."
For claification the header PKs are ProjectID and RevisionID and detail PKs are thesame fields plus TranPeriodID.
Here is my Graph:
public class PMCashflowProjectionEntry : PXGraph<PMCashflowProjectionEntry, PMCashflowProjection>
{
[PXViewName("Projects Cashflow Projections")]
public PXSelect<PMCashflowProjection> CashflowProjections;
public PXSelect<PMCashflowProjectionSchedule,
Where<PMCashflowProjectionSchedule.projectID, Equal<Current<PMCashflowProjection.projectID>>,
And<PMCashflowProjectionSchedule.revisionID, Equal<Current<PMCashflowProjection.revisionID>>>>> CashflowProjectionSchedules;
protected void PMCashflowProjection_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
PMCashflowProjection cashflowProjections = CashflowProjections.Current;
if (cashflowProjections == null)
{
return;
}
else
{
#region Set Projection Visibility
bool OriginalIsEnabled = (cashflowProjections.OriginalIsLocked == true) ? false : true;
bool RevisionIsEnabled = (cashflowProjections.RevisionIsLocked == true) ? false : true;
PXUIFieldAttribute.SetEnabled<PMCashflowProjection.originalCost>(cache, null, OriginalIsEnabled);
PXUIFieldAttribute.SetEnabled<PMCashflowProjection.originalFee>(cache, null, OriginalIsEnabled);
PXUIFieldAttribute.SetEnabled<PMCashflowProjection.revisedCost>(cache, null, RevisionIsEnabled);
PXUIFieldAttribute.SetEnabled<PMCashflowProjection.revisedFee>(cache, null, RevisionIsEnabled);
#endregion
}
}
protected void PMCashflowProjectionSchedule_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
PMCashflowProjection cashflowProjections = CashflowProjections.Current;
if (cashflowProjections == null)
{
return;
}
else
{
#region Calculate Roll-up Fields
cashflowProjections.OriginalValueRollup = 0m;
cashflowProjections.RevisedValueRollup = 0m;
foreach (PMCashflowProjectionSchedule cashflowProjectionSchedules in this.CashflowProjectionSchedules.Select())
{
cashflowProjections.OriginalValueRollup += cashflowProjectionSchedules.OriginalValue.GetValueOrDefault();
cashflowProjections.RevisedValueRollup += cashflowProjectionSchedules.RevisedValue.GetValueOrDefault();
}
CashflowProjections.Update(cashflowProjections);
CashflowProjectionSchedules.View.RequestRefresh();
#endregion
}
if (cashflowProjections == null)
{
return;
}
else
{
#region Set Projection Schedule Visibility
bool OriginalIsEnabled = (cashflowProjections.OriginalIsLocked == true) ? false : true;
bool RevisionIsEnabled = (cashflowProjections.RevisionIsLocked == true) ? false : true;
PXUIFieldAttribute.SetEnabled<PMCashflowProjectionSchedule.originalPercent>(cache, null, OriginalIsEnabled);
PXUIFieldAttribute.SetEnabled<PMCashflowProjectionSchedule.originalCost>(cache, null, OriginalIsEnabled);
PXUIFieldAttribute.SetEnabled<PMCashflowProjectionSchedule.originalFee>(cache, null, OriginalIsEnabled);
PXUIFieldAttribute.SetEnabled<PMCashflowProjectionSchedule.revisedPercent>(cache, null, RevisionIsEnabled);
PXUIFieldAttribute.SetEnabled<PMCashflowProjectionSchedule.revisedCost>(cache, null, RevisionIsEnabled);
PXUIFieldAttribute.SetEnabled<PMCashflowProjectionSchedule.revisedFee>(cache, null, RevisionIsEnabled);
#endregion
}
}
}
and here is my ASPX
<%@ Page Language="C#" MasterPageFile="~/MasterPages/FormTab.master" AutoEventWireup="true" ValidateRequest="false" CodeFile="PM904000.aspx.cs" Inherits="Page_PM904000" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPages/FormTab.master" %>
<asp:Content ID="cont1" runat="Server" ContentPlaceHolderID="phDS">
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%" TypeName="LGCustom.PMCashflowProjectionEntry" PrimaryView="CashflowProjections" BorderStyle="NotSet">
<CallbackCommands>
</CallbackCommands>
</px:PXDataSource>
</asp:Content>
<asp:Content ID="cont2" runat="Server" ContentPlaceHolderID="phF">
<px:PXFormView ID="form" runat="server" DataSourceID="ds" Style="z-index: 100" Width="100%" Height="150px" AllowAutoHide="true" DataMember="CashflowProjections" Caption="" FilesIndicator="True" NoteindIcator="True" DefaultControlID="edProjectID">
<Template>
<px:PXLayoutRule runat="server" ID="PXLayoutRule1" StartColumn="True" ControlSize="XM" LabelsWidth ="SM" ></px:PXLayoutRule>
<px:PXSegmentMask runat="server" ID="edBranchID" DataField="BranchID" AutoCallBack="True" />
<px:PXSegmentMask runat="server" ID="edProjectID" DataField="ProjectID" />
<px:PXSelector runat="server" ID="edRevisionID" DataField="RevisionID" AutoRefresh="True" />
<px:PXCheckBox runat="server" ID="chkOriginalIsLocked" DataField="OriginalIsLocked" CommitChanges="True" ></px:PXCheckBox>
<px:PXCheckBox runat="server" ID="chkRevisionIsLocked" DataField="RevisionIsLocked" CommitChanges="True" ></px:PXCheckBox>
<px:PXNumberEdit runat="server" ID="edOriginalValueRollup" DataField="OriginalValueRollup" />
<px:PXNumberEdit runat="server" ID="edRevisedValueRollup" DataField="RevisedValueRollup" />
</Template>
</px:PXFormView>
</asp:Content>
<asp:Content ID="cont3" runat="Server" ContentPlaceHolderID="phG">
<px:PXTab ID="tab" runat="server" DataSourceID="ds" DataMember="CashflowProjectionSchedules" Width="100%" Height="300px" AllowAutoHide="false">
<Activity HighlightColor="" SelectedColor="" Width="" Height=""></Activity>
<Items>
<px:PXTabItem Text="Schedule" Visible="true">
<Template>
<px:PXGrid ID="CashflowProjectionSchedulesGrid" runat="server" DataSourceID="ds" Style="z-index: 100" Width="100%" Height="300px" SkinID="DetailsInTab" OnRowDataBound="grid_RowDataBound">
<Levels>
<px:PXGridLevel DataMember="CashflowProjectionSchedules">
<RowTemplate>
</RowTemplate>
<Columns>
<px:PXGridColumn DataField="ProjectID" Width="80" AutoCallBack="True" ></px:PXGridColumn>
<px:PXGridColumn DataField="RevisionID" Width="80" AutoCallBack="True" ></px:PXGridColumn>
<px:PXGridColumn DataField="TranDate" AutoCallBack="True" Width="70" ></px:PXGridColumn>
<px:PXGridColumn DataField="TranPeriodID" CommitChanges="True" Width="70" ></px:PXGridColumn>
<px:PXGridColumn DataField="FinPeriodID" AutoCallBack="True" Width="70" ></px:PXGridColumn>
<px:PXGridColumn DataField="OriginalPercent" Width="80" CommitChanges="True" ></px:PXGridColumn>
<px:PXGridColumn DataField="OriginalCost" Width="100" CommitChanges="True" AutoCallBack="True" ></px:PXGridColumn>
<px:PXGridColumn DataField="OriginalFee" Width="100" CommitChanges="True" AutoCallBack="True" ></px:PXGridColumn>
<px:PXGridColumn DataField="OriginalValue" Width="100" CommitChanges="True" AutoCallBack="True" ></px:PXGridColumn>
<px:PXGridColumn DataField="RevisedPercent" Width="80" CommitChanges="True" ></px:PXGridColumn>
<px:PXGridColumn DataField="RevisedCost" Width="100" CommitChanges="True" AutoCallBack="True" ></px:PXGridColumn>
<px:PXGridColumn DataField="RevisedFee" Width="100" CommitChanges="True" AutoCallBack="True" ></px:PXGridColumn>
<px:PXGridColumn DataField="RevisedValue" Width="100" CommitChanges="True" AutoCallBack="True" ></px:PXGridColumn>
<px:PXGridColumn DataField="Comment" Width="300" ></px:PXGridColumn>
<px:PXGridColumn DataField="BranchID" Width="140" AutoCallBack="True" ></px:PXGridColumn>
<px:PXGridColumn DataField="RevisionDate" AutoCallBack="True" Width="70" ></px:PXGridColumn>
</Columns>
</px:PXGridLevel>
</Levels>
<AutoSize Enabled="True" />
</px:PXGrid>
</Template>
</px:PXTabItem>
</Items>
<AutoSize Container="Window" Enabled="True" MinHeight="300" MinWidth="300" ></AutoSize>
</px:PXTab>
</asp:Content>