You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

网格字段筛选功能咨询及Selector未同步更新问题求助

Fixing Selector Not Updating After Grid Field Filtering in Acumatica

Hey there! Let's dig into your issue. First off, yes—you absolutely can filter fields within a grid in Acumatica—we just need to adjust your setup to get that Selector behaving as expected when you filter.

Looking at your code, the core problem is likely how the Selector is tied to the stateID value in the grid. When working with grid rows, the Current<stateID> reference might not reliably pick up the active row's value, especially after filtering. Here's how to fix it:

Step 1: Add AutoRefresh to the Selector

First, update your PXSelector attribute to include AutoRefresh = true. This tells Acumatica to automatically re-run the Selector's query whenever the linked stateID field changes (including when you filter rows in the grid).

Here's your modified code snippet:

#region CategoryID
[PXDBInt()]
[PXUIField(DisplayName = "Category ID")]
[PXSelector(
    typeof(Search<PESKPriceIndexCat.categoryID, 
        Where<PESKPriceIndexCat.state, Equal<Current<YourDACName.stateID>>, 
            And<PESKPriceIndexCat.active, Equal<True>>>>),
    typeof(PESKPriceIndexCat.categoryID),
    typeof(PESKPriceIndexCat.categoryCD),
    typeof(PESKPriceIndexCat.descripcion),
    DescriptionField = typeof(PESKPriceIndexCat.descripcion),
    SubstituteKey = typeof(PESKPriceIndexCat.categoryCD),
    AutoRefresh = true // This triggers a refresh when stateID changes
)]
public virtual int? CategoryID { get; set; }
public abstract class categoryID : PX.Data.BQL.BqlInt.Field<categoryID> { }
#endregion

Note: Replace YourDACName with the actual name of the DAC that contains both CategoryID and stateID.

Step 2: Verify Your stateID Field Definition

Make sure the stateID field in your main DAC is properly defined so Acumatica can track its value changes. A basic example would look like this:

#region StateID
[PXDBString(50)] // Adjust the data type to match your database setup
[PXUIField(DisplayName = "State ID")]
public virtual string StateID { get; set; }
public abstract class stateID : PX.Data.BQL.BqlString.Field<stateID> { }
#endregion

Step 3: Add a RowSelected Event (If Needed)

If the AutoRefresh alone doesn't fix the issue, you can force the Selector to refresh whenever a grid row is selected or updated by adding a RowSelected event handler to your Graph:

protected virtual void YourDACName_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
    var currentRow = (YourDACName)e.Row;
    if (currentRow == null) return;

    // Refresh the CategoryID Selector based on the current row's StateID
    var categorySelector = cache.GetStateExt<YourDACName.categoryID>(currentRow) as PXSelectorState;
    if (categorySelector != null)
    {
        cache.ClearQueryCache<YourDACName.categoryID>();
        cache.SetStateExt<YourDACName.categoryID>(currentRow, categorySelector);
    }
}

This ensures that every time a row is loaded or selected, the Selector re-runs its query with the current row's stateID value.

Final Checks

  • Make sure the PESKPriceIndexCat DAC's state field matches the data type of your main DAC's stateID field (e.g., both int? or both string). Mismatched types will break the filter.
  • Test filtering the grid by stateID—the CategoryID Selector should now only show options where PESKPriceIndexCat.state matches the row's stateID and active is True.

内容的提问来源于stack exchange,提问作者Tibu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:12:49