保存记录时插入网格线
Insert a grid line when the record gets saved
我正在尝试在持久逻辑期间向网格添加新记录。但是,即使记录确实添加到 UI 中的网格中,当页面刷新时,新行也会消失。它没有在数据库中持久化。
我正在使用 账单 页面作为参考。
代码示例
protected virtual void APTran_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
if (e.Row == null)
{
return;
}
APInvoice invoiceRow = this.Base.Document.Current;
if (invoiceRow != null)
{
APTran tranRow = new APTran();
tranRow = this.Base.Transactions.Insert(tranRow);
tranRow.InventoryID = 10043;
this.Base.Transactions.Update(tranRow);
tranRow.Qty = 3;
this.Base.Transactions.Update(tranRow);
}
}
保存后的结果 - 记录显示在网格中:
取消后的结果 - 记录从网格中消失:
类似这样的事情我倾向于在调用base persist 之前重写Persist 方法并插入或更新相关记录。这是您的图形扩展中的一个可能示例:
[PXOverride]
public virtual void Persist(Action del)
{
foreach(APInvoice invoiceRow in Base.Document.Cache.Inserted)
{
APTran tranRow = this.Base.Transactions.Insert();
tranRow.InventoryID = 10043;
tranRow = this.Base.Transactions.Update(tranRow);
tranRow.Qty = 3;
this.Base.Transactions.Update(tranRow);
}
del?.Invoke();
}
我正在尝试在持久逻辑期间向网格添加新记录。但是,即使记录确实添加到 UI 中的网格中,当页面刷新时,新行也会消失。它没有在数据库中持久化。
我正在使用 账单 页面作为参考。
代码示例
protected virtual void APTran_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
if (e.Row == null)
{
return;
}
APInvoice invoiceRow = this.Base.Document.Current;
if (invoiceRow != null)
{
APTran tranRow = new APTran();
tranRow = this.Base.Transactions.Insert(tranRow);
tranRow.InventoryID = 10043;
this.Base.Transactions.Update(tranRow);
tranRow.Qty = 3;
this.Base.Transactions.Update(tranRow);
}
}
保存后的结果 - 记录显示在网格中:
取消后的结果 - 记录从网格中消失:
类似这样的事情我倾向于在调用base persist 之前重写Persist 方法并插入或更新相关记录。这是您的图形扩展中的一个可能示例:
[PXOverride]
public virtual void Persist(Action del)
{
foreach(APInvoice invoiceRow in Base.Document.Cache.Inserted)
{
APTran tranRow = this.Base.Transactions.Insert();
tranRow.InventoryID = 10043;
tranRow = this.Base.Transactions.Update(tranRow);
tranRow.Qty = 3;
this.Base.Transactions.Update(tranRow);
}
del?.Invoke();
}