如何解决为什么我的PXSmartPanel第一次执行后不能显示正确的数据? 更新:
我正在使用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.",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帖子清除数据,但这似乎没有任何区别。
这是我的ASPX:
我想念什么?
更新:
最适合我的代码是这样:
MixSizeDialog.View.Clear();
if (MixSizeDialog.AskExt((graph,view) =>
{
MixSizeDialog.Cache.Clear();
MixSizeDialog.Current = new MXMixSize() { BatchSize = batchWt * 100,true) != WebDialogResult.OK) return;
另外,在ASPX中,AutoRepaint
和AutoReload
(可能还有Loadondemand
)必须为真。
解决方法
您可以做/检查一些事情来解决此问题:
- 使用AskExt调用智能面板视图时,请确保将重新加载指定为true。例如:SmartPanelView.AskExt(true)。
- 确保将智能面板定义上的AutoReload,LoadonDemand和AutoRepaint属性设置为true。
您也可以在调用AskExt方法之前尝试从智能面板视图中清除缓存,但是如果为重载指定为true,则不需要这样做。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。