【问题标题】:FGetting a Form Field from a grid extension从网格扩展中获取表单域
【发布时间】:2018-04-18 01:00:38
【问题描述】:

我在“准备补货”表单中添加了一个字段,当用户在“补货项目”网格中选择一行时需要更新该字段。我如何访问该字段。我知道它在 INReplenishmentFilterExt 中,但我不知道如何访问扩展。

编辑 #1:我能够获取字段的值,但是当我使用 cache.SetValue 时它不会在屏幕上更新。我正在尝试从 Selected 事件处理程序内部更新此过滤器扩展字段。

protected void INReplenishmentItem_Selected_FieldUpdating(PXCache cache, PXFieldUpdatingEventArgs e)
{
    var row = (INReplenishmentItem)e.Row;
    if (row == null)
        return;
    INReplenishmentFilter filter = Base.Filter.Current;
    INReplenishmentFilterExt filterExt = PXCache<INReplenishmentFilter>.GetExtension<INReplenishmentFilterExt>(filter);

    decimal poAmount = filterExt.UsrPOAmount.HasValue ? filterExt.UsrPOAmount.Value : 0;
    decimal lastPrice = pvi.LastPrice.HasValue ? pvi.LastPrice.Value : 0;
    decimal newPOAmount = poAmount + lastPrice;

    cache.SetValue<INReplenishmentFilterExt.usrPOAmount>(filterExt, newPOAmount);
}

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    不能使用 INReplenishmentItem 的 Cache 来设置 Filter 的值。 我已经编辑了我的答案,下面的代码应该可以工作。

    //Always use virtual methods for Event Handlers
    protected virtual void INReplenishmentItem_Selected_FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
    {
        //Try not to use vars. Especially when you know the Type of the object
        INReplenishmentItem row = e.Row as INReplenishmentItem;
    
        if (row != null)
        {
            INReplenishmentFilter filter = Base.Filter.Current;
            INReplenishmentFilterExt filterExt = PXCache<INReplenishmentFilter>.GetExtension<INReplenishmentFilterExt>(filter);
    
            decimal poAmount = filterExt.UsrPOAmount ?? 0;
            decimal lastPrice = pvi.LastPrice ?? 0;//Not sure what pvi is
            decimal newPOAmount = poAmount + lastPrice;
    
            //"sender" is the cache that specifically stores the datatype of row
            //Therefor you cannot use it to update records of a different datatype
            //You also should not pass an Extension into the argument that should be the row object you are trying to update
            Base.Filter.Cache.SetValueExt<INReplenishmentFilterExt.usrPOAmount>(filter, newPOAmount);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-11
      相关资源
      最近更新 更多