为什么我的PXSmartPanel第一次执行后不能显示正确的数据? [英] Why won't my PXSmartPanel display the correct data after the first execution?

查看:52
本文介绍了为什么我的PXSmartPanel第一次执行后不能显示正确的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PXSmartPanel显示当前行中的数据,并允许用户在操作该数据之前做出选择.

I am using a PXSmartPanel to display data from the current row and allow the user to make a choice before manipulating that data.

第一次执行完美无缺.但是,后续执行将显示第一个执行的数据.我认为这与代码无关,但这是对话框调用:

The first execution works flawlessly. However, subsequent executions display the first execution's data. I don't think it's code related, but here's the dialog call:

    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帖子清除数据,但这似乎没有任何区别.

As you can see, my variables are initialized in the block which means they cannot preserve the previous rows values. I added the three lines in the dialog call to clear the data based upon another SO post, but it does not seem to make any difference.

这是我的ASPX:

我想念什么?

对我来说正确的代码是:

The code that works correctly for me is this:

        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中必须为真.

Additionally, AutoRepaint and AutoReload (and possibly LoadOnDemand) must be true in ASPX.

推荐答案

您可以执行/检查以下几项操作来解决此问题:

There are a couple of things you can do/check in order to resolve this:

  1. 使用AskExt调用智能面板视图时,请确保将重新加载指定为true.例如:SmartPanelView.AskExt(true).
  2. 确保将智能面板定义上的AutoReload,LoadonDemand和AutoRepaint属性设置为true.

您还可以在调用AskExt方法之前尝试从智能面板视图中清除缓存,但是如果为重载指定为true,则不需要这样做.

You can also try and clear the cache from the smart panel view before calling the AskExt method, but if you specify true for the reload there shouldn't be any need for this.

这篇关于为什么我的PXSmartPanel第一次执行后不能显示正确的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆