Cache notified about the modification of the field in the row, only when grid row selection is changed.
I have a grid with one editable record in the row: KiwiSaver status:
I added validation error and control enabled/disabled state of "save & export" button in the event row_selected
:
protected virtual void MPNewDepartingEmployeesBatchItem_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
var row = e.Row as MPNewDepartingEmployeesBatchItem;
if (row.IsNull()) return;
AllEmployeesTransactions.Cache.RaiseExceptionHandling<MPNewDepartingEmployeesBatchItem.kiwiSaverStatus>(
row, row.KiwiSaverStatus,
string.IsNullOrEmpty(row.KiwiSaverStatus)
? new PXSetPropertyException("KiwiSaver Status is not specified.", PXErrorLevel.Error)
: null);
SaveAndExportBatchAction.SetEnabled(!(cache.Inserted.Cast<MPNewDepartingEmployeesBatchItem>().Any(a => string.IsNullOrEmpty(a.KiwiSaverStatus)) ||
cache.Updated.Cast<MPNewDepartingEmployeesBatchItem>().Any(a => string.IsNullOrEmpty(a.KiwiSaverStatus))));
}
This event raised only when selection changed, and NOT directly when I change the item in the Drop Down. Means, to apply the change, user MUST change the selection. All events I tried also raised after selection in the grid is changed. For instance:
public virtual void MPNewDepartingEmployeesBatchItem_KiwiSaverStatus_FieldUpdated(PXCache cache,
PXFieldUpdatedEventArgs e)
{
}
public virtual void MPNewDepartingEmployeesBatchItem_KiwiSaverStatus_FieldUpdating(PXCache cache,
PXFieldUpdatingEventArgs e)
{
}
protected virtual void MPNewDepartingEmployeesBatchItem_KiwiSaverStatus_FieldVerifying(
PXCache sender, PXFieldVerifyingEventArgs e)
{
}
My grid looks like this:
<px:PXGrid ID="grid" runat="server" DataSourceID="ds" Style="z-index: 100" AutoAdjustColumns="True"
Width="100%" Height="150px" SkinID="PrimaryInquire" TabIndex="100" AllowShowHide="Server" StatusField="ErrorMessage"
AllowSearch="True" FastFilterFields="Surname,Firstname,IRDNumber" RestrictFields="True" SyncPosition="True">
<AutoSize Container="Window" Enabled="True" MinHeight="200" />
<Levels>
<px:PXGridLevel DataMember="AllEmployeesTransactions" Key="IRBatchItemID">
<RowTemplate>
<px:PXTextEdit ID="Surname" runat="server" DataField="Surname" />
<px:PXTextEdit ID="MiddleName" runat="server" DataField="MiddleName" />
<px:PXTextEdit ID="EmployeeTitle" runat="server" DataField="EmployeeTitle" />
<px:PXTextEdit ID="IRDNumber" runat="server" DataField="IRDNumber" />
<px:PXTextEdit ID="BranchCD" runat="server" DataField="BranchCD" />
<px:PXTextEdit ID="TaxCode" runat="server" DataField="TaxCode" />
<px:PXTextEdit ID="EmployeeDOBDateTime1" runat="server" DataField="EmployeeDOBDateTime" />
<px:PXTextEdit ID="EmployeeStartDate" runat="server" DataField="EmployeeStartDate" />
<px:PXTextEdit ID="EmployeeEndDate" runat="server" DataField="EmployeeEndDate" />
<px:PXDropDown ID="KiwiSaverStatus" runat="server"
DataField="KiwiSaverStatus"
CommitChanges="True" />
<px:PXTextEdit ID="EmailAddress" runat="server" DataField="EmailAddress" />
<px:PXTextEdit ID="MobilePhoneNumber" runat="server" DataField="MobilePhoneNumber" />
<px:PXTextEdit ID="DaytimePhoneNumber" runat="server" DataField="DaytimePhoneNumber" />
<px:PXTextEdit ID="Country" runat="server" DataField="Country" />
<px:PXTextEdit ID="StreetName" runat="server" DataField="StreetName" />
<px:PXTextEdit ID="City" runat="server" DataField="City" />
<px:PXTextEdit ID="PostCode" runat="server" DataField="PostCode" />
<px:PXTextEdit ID="State" runat="server" DataField="State" />
</RowTemplate>
<Columns>
<px:PXGridColumn DataField="Surname" LinkCommand="payDetailsAction" />
<px:PXGridColumn DataField="Firstname" />
<px:PXGridColumn DataField="MiddleName">
</px:PXGridColumn>
<px:PXGridColumn DataField="EmployeeTitle">
</px:PXGridColumn>
<px:PXGridColumn DataField="IRDNumber">
</px:PXGridColumn>
<px:PXGridColumn DataField="BranchCD">
</px:PXGridColumn>
<px:PXGridColumn DataField="TaxCode">
</px:PXGridColumn>
<px:PXGridColumn DataField="EmployeeDOBDateTime">
</px:PXGridColumn>
<px:PXGridColumn DataField="EmployeeStartDate">
</px:PXGridColumn>
<px:PXGridColumn DataField="EmployeeEndDate">
</px:PXGridColumn>
<px:PXGridColumn DataField="KiwiSaverStatus"
Type="DropDownList"
CommitChanges="True">
</px:PXGridColumn>
<px:PXGridColumn DataField="EmailAddress">
</px:PXGridColumn>
<px:PXGridColumn DataField="MobilePhoneNumber">
</px:PXGridColumn>
<px:PXGridColumn DataField="DaytimePhoneNumber">
</px:PXGridColumn>
<px:PXGridColumn DataField="Country">
</px:PXGridColumn>
<px:PXGridColumn DataField="StreetName">
</px:PXGridColumn>
<px:PXGridColumn DataField="City">
</px:PXGridColumn>
<px:PXGridColumn DataField="PostCode">
</px:PXGridColumn>
<px:PXGridColumn DataField="State">
</px:PXGridColumn>
</Columns>
</px:PXGridLevel>
</Levels>
<ActionBar ActionsText="False" DefaultAction="payDetailsAction">
<Actions>
<AddNew MenuVisible="false" ToolBarVisible="false"></AddNew>
<Delete MenuVisible="false" ToolBarVisible="false"></Delete>
<Refresh MenuVisible="False" ToolBarVisible="False"></Refresh>
</Actions>
<CustomItems>
<px:PXToolBarButton Text="View Pay Details" Key="payDetailsAction" Tooltip="View pay details the currently selected employee" Visible="False">
<AutoCallBack Command="PayDetailsAction" Target="ds">
</AutoCallBack>
</px:PXToolBarButton>
</CustomItems>
</ActionBar>
<Mode AllowAddNew="false" AllowDelete="false" />
</px:PXGrid>
What do I need to do to inform my Graph that Record in the row has changed directly? For instance in WPF we have UpdateSourceTrigger="PropertyChanged"
I will be very grateful for any advice.