为什么两个相同类型的视图不能正确返回当前行?

问题描述

自定义屏幕上,我定义了两个 相同 视图,如下所示:

    public PXSelectJoin<MXMix,InnerJoin<MXBatch,On<MXBatch.batchID,Equal<MXMix.batchID>>,InnerJoin<SOLine,On<SOLine.orderType,Equal<MXBatch.soOrderType>,And<SOLine.orderNbr,Equal<MXBatch.soOrderNbr>,And<SOLine.lineNbr,Equal<MXBatch.soLineNbr>>>>,InnerJoin<Customer,On<Customer.bAccountID,Equal<SOLine.customerID>>,LeftJoin<Address,On<Address.addressID,Equal<Customer.defAddressID>>,LeftJoin<INLocation,On<INLocation.locationID,Equal<MXMix.locationID>>>>>>>> MixesBlk;
    
    public PXSelectJoin<MXMix,Equal<MXMix.locationID>>>>>>>> MixesBag;

(出于价值考虑,页面主视图是同一类型。)

它们每个都有一个数据视图委托,它们也与 相同 相同,除了将bagsbulk分开的一个条件。

这些视图绑定到两个单独的数据网格,它们正确显示与数据视图委托条件匹配的记录(图1)。

enter image description here

问题是,当我尝试从任一网格中获取选定的行时,无论数据视图委托条件如何,它仅从数据库返回第一行。

此外,我在两个网格上都启用了SyncPosition

我做错了什么吗,还是这在Acumatica中是一个限制?

解决方法

视图的Current属性实际上映射到后台图形的Caches字典。这是在PXSelect上实现Current属性的方式:

        /// <summary>Gets or sets the <tt>Current</tt> property of the cache that
        /// corresponds to the DAC specified in the type parameter.</summary>
        public virtual Table Current
        {
            get
            {
                return (Table)View.Cache.Current;
            }
            set
            {
                View.Cache.Current = value;
            }
        }

PXView.Cache实现是:

        /// <summary>Gets the cache corresponding to the first DAC mentioned in
        /// the BQL command.</summary>
        public virtual PXCache Cache
        {
            get
            {
                if (_Cache == null || _Graph.stateLoading)
                {
                    _Cache = Graph.Caches[CacheType];
                }
                return _Cache;
            }
        }

MixesBlk.CurrentMixesBag.Current都使用相同的基础缓存,而检索其他视图的当前属性将等同于Caches[typeof(MXMix)].Current

您采用的解决方案与我曾经使用的解决方案相同-通过创建继承类型,可以确保两个视图在图形中具有不同的缓存。您将在Acumatica的两个地方找到使用这种模式。