为什么我的 PXSmartPanel 在第一次执行后不能显示正确的数据?
Why won't my PXSmartPanel display the correct data after the first execution?
我正在使用 PXSmartPanel 显示当前行的数据并允许用户在操作该数据之前做出选择。
第一次执行完美无缺。但是,后续执行会显示第一次执行的数据。我认为这与代码无关,但这是对话调用:
public PXAction<MXBatch> moveToQueue;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "MoveToQueue")]
protected virtual void MoveToQueue()
{
MXBatch selectedBatch = Batches.Current;
if (selectedBatch == null) return;
// Select batch and check for existing mixes
var batchGraph = PXGraph.CreateInstance<MXBatchEntry>();
batchGraph.Document.Current = batchGraph.Document.Search<MXBatch.batchID>(selectedBatch.BatchID);
if (batchGraph.Transactions.Select().Count > 0)
{
Batches.Ask("Already Converted", "This batch already has at least one mix associated with it. This action will be cancelled.", MessageButtons.OK, MessageIcon.Error);
return;
}
var soGraph = PXGraph.CreateInstance<SOOrderEntry>();
soGraph.Document.Search<SOOrder.orderType, SOOrder.orderNbr>(selectedBatch.SOOrderType, selectedBatch.SOOrderNbr);
SOLine soLine = soGraph.Transactions.Search<SOLine.lineNbr>(selectedBatch.SOLineNbr);
// Check if Sales Order line exists
if (soLine == null) Batches.Ask("Missing Sales Order", "The Sales Order item associated with this mix cannot be found. This action will be cancelled.", MessageButtons.OK, MessageIcon.Error);
// Calculate the current batch weight in CWT
decimal batchWt = 0m;
batchWt = INUnitAttribute.ConvertFromTo<SOLine.inventoryID>(soGraph.Transactions.Cache, soLine, soLine.UOM, setup.Current.CwtUOM, soLine.Qty ?? 0, INPrecision.QUANTITY);
// Calculate the number of mixes
int maxMixWt = 60; // in CWT
int mixNbr = (int)Math.Ceiling(batchWt / maxMixWt);
decimal rcmdMixWt = batchWt / (mixNbr < 1 ? 1 : mixNbr);
// Popup displaying recommended action and allow for change
if (MixSizeDialog.AskExt((graph, view) =>
{
MixSizeDialog.Cache.ClearQueryCache();
MixSizeDialog.View.Clear();
MixSizeDialog.ClearDialog();
MixSizeDialog.Current = new MXMixSize() { BatchSize = batchWt * 100, MixSize = rcmdMixWt * 100, MixNbr = mixNbr };
}, true) != WebDialogResult.OK) return;
mixNbr = (MixSizeDialog.Current.MixNbr ?? 0);
mixNbr = mixNbr < 1 ? 1 : mixNbr;
// Calculate the size of each mix
decimal mixWt = soLine.Qty.Value / mixNbr;
// Create mixes
for (int i = 0; i < mixNbr; i++)
{
MXMix mix = Mixes.Insert(new MXMix());
Mixes.SetValueExt<MXMix.qty>(mix, mixWt);
Mixes.SetValueExt<MXMix.uom>(mix, soLine.UOM);
Mixes.SetValueExt<MXMix.status>(mix, "QUD");
Mixes.Update(mix);
}
Batches.SetValueExt<MXBatch.status>(selectedBatch, 1);
Batches.Update(selectedBatch);
Actions.PressSave();
}
如您所见,我的变量是在块中初始化的,这意味着它们无法保留以前的行值。我在对话框调用中添加了三行以清除基于另一个 SO post 的数据,但它似乎没有任何区别。
这是我的 ASPX:
我错过了什么?
更新:
对我来说正确的代码是这样的:
MixSizeDialog.View.Clear();
if (MixSizeDialog.AskExt((graph, view) =>
{
MixSizeDialog.Cache.Clear();
MixSizeDialog.Current = new MXMixSize() { BatchSize = batchWt * 100, MixSize = rcmdMixWt * 100, MixNbr = mixNbr };
}, true) != WebDialogResult.OK) return;
此外,AutoRepaint
和 AutoReload
(可能还有 LoadOnDemand
)在 ASPX 中必须为真。
为了解决这个问题,您可以 do/check 采取一些措施:
- 使用 AskExt 调用智能面板视图时,请确保将重新加载指定为 true。例如:SmartPanelView.AskExt(真)。
- 确保智能面板定义中的 AutoReload、LoadonDemand 和 AutoRepaint 属性设置为 true。
您也可以在调用 AskExt 方法之前尝试从智能面板视图中清除缓存,但如果您为重新加载指定 true,则不需要这样做。
我正在使用 PXSmartPanel 显示当前行的数据并允许用户在操作该数据之前做出选择。
第一次执行完美无缺。但是,后续执行会显示第一次执行的数据。我认为这与代码无关,但这是对话调用:
public PXAction<MXBatch> moveToQueue;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "MoveToQueue")]
protected virtual void MoveToQueue()
{
MXBatch selectedBatch = Batches.Current;
if (selectedBatch == null) return;
// Select batch and check for existing mixes
var batchGraph = PXGraph.CreateInstance<MXBatchEntry>();
batchGraph.Document.Current = batchGraph.Document.Search<MXBatch.batchID>(selectedBatch.BatchID);
if (batchGraph.Transactions.Select().Count > 0)
{
Batches.Ask("Already Converted", "This batch already has at least one mix associated with it. This action will be cancelled.", MessageButtons.OK, MessageIcon.Error);
return;
}
var soGraph = PXGraph.CreateInstance<SOOrderEntry>();
soGraph.Document.Search<SOOrder.orderType, SOOrder.orderNbr>(selectedBatch.SOOrderType, selectedBatch.SOOrderNbr);
SOLine soLine = soGraph.Transactions.Search<SOLine.lineNbr>(selectedBatch.SOLineNbr);
// Check if Sales Order line exists
if (soLine == null) Batches.Ask("Missing Sales Order", "The Sales Order item associated with this mix cannot be found. This action will be cancelled.", MessageButtons.OK, MessageIcon.Error);
// Calculate the current batch weight in CWT
decimal batchWt = 0m;
batchWt = INUnitAttribute.ConvertFromTo<SOLine.inventoryID>(soGraph.Transactions.Cache, soLine, soLine.UOM, setup.Current.CwtUOM, soLine.Qty ?? 0, INPrecision.QUANTITY);
// Calculate the number of mixes
int maxMixWt = 60; // in CWT
int mixNbr = (int)Math.Ceiling(batchWt / maxMixWt);
decimal rcmdMixWt = batchWt / (mixNbr < 1 ? 1 : mixNbr);
// Popup displaying recommended action and allow for change
if (MixSizeDialog.AskExt((graph, view) =>
{
MixSizeDialog.Cache.ClearQueryCache();
MixSizeDialog.View.Clear();
MixSizeDialog.ClearDialog();
MixSizeDialog.Current = new MXMixSize() { BatchSize = batchWt * 100, MixSize = rcmdMixWt * 100, MixNbr = mixNbr };
}, true) != WebDialogResult.OK) return;
mixNbr = (MixSizeDialog.Current.MixNbr ?? 0);
mixNbr = mixNbr < 1 ? 1 : mixNbr;
// Calculate the size of each mix
decimal mixWt = soLine.Qty.Value / mixNbr;
// Create mixes
for (int i = 0; i < mixNbr; i++)
{
MXMix mix = Mixes.Insert(new MXMix());
Mixes.SetValueExt<MXMix.qty>(mix, mixWt);
Mixes.SetValueExt<MXMix.uom>(mix, soLine.UOM);
Mixes.SetValueExt<MXMix.status>(mix, "QUD");
Mixes.Update(mix);
}
Batches.SetValueExt<MXBatch.status>(selectedBatch, 1);
Batches.Update(selectedBatch);
Actions.PressSave();
}
如您所见,我的变量是在块中初始化的,这意味着它们无法保留以前的行值。我在对话框调用中添加了三行以清除基于另一个 SO post 的数据,但它似乎没有任何区别。
这是我的 ASPX:
我错过了什么?
更新:
对我来说正确的代码是这样的:
MixSizeDialog.View.Clear();
if (MixSizeDialog.AskExt((graph, view) =>
{
MixSizeDialog.Cache.Clear();
MixSizeDialog.Current = new MXMixSize() { BatchSize = batchWt * 100, MixSize = rcmdMixWt * 100, MixNbr = mixNbr };
}, true) != WebDialogResult.OK) return;
此外,AutoRepaint
和 AutoReload
(可能还有 LoadOnDemand
)在 ASPX 中必须为真。
为了解决这个问题,您可以 do/check 采取一些措施:
- 使用 AskExt 调用智能面板视图时,请确保将重新加载指定为 true。例如:SmartPanelView.AskExt(真)。
- 确保智能面板定义中的 AutoReload、LoadonDemand 和 AutoRepaint 属性设置为 true。
您也可以在调用 AskExt 方法之前尝试从智能面板视图中清除缓存,但如果您为重新加载指定 true,则不需要这样做。