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

动态隐藏网格中selector重复值并禁用库存ID跳转链接的实现问题

修正代码

你可以直接使用调整后的代码,同时解决显示空值和禁用跳转的问题:

protected void _(Events.FieldSelecting<FPPriceSheetDetail, FPPriceSheetDetail.inventoryID> e)
{
    if (e.Row is null) return;
    if (e.Row.RowType == FPPriceSheetRowType.BreakQty) return;
    
    var state = PXFieldState.CreateInstance(e.ReturnState, typeof(string), true, false, 1, null, null, null, nameof(FPPriceSheetDetail.inventoryID));
    // 禁用Selector全部交互,移除跳转链接
    state.SelectorMode = PXSelectorMode.NoSelector;
    // 清空描述文本显示
    state.DescriptionValue = string.Empty;
    state.DescriptionName = string.Empty;
    state.ValueField = string.Empty;
    // 禁止字段编辑,避免误操作
    state.Enabled = false;
    state.Visibility = PXUIVisibility.Visible;
    state.Visible = true;

    e.ReturnState = state;
    e.ReturnValue = string.Empty;
    // 阻止框架后续覆盖你的赋值
    e.Cancel = true;
}

关键修改说明

  • 你之前的代码只清空了ReturnValue,但Selector的描述文本是独立存储的,新增DescriptionValue = string.Empty即可把描述也设为空
  • 把SelectorMode从TextMode改为NoSelector,直接移除Selector的所有交互逻辑,自然不会生成跳转链接,也就不会出现用户误点跳转到库存物料页面的问题
  • 新增e.Cancel = true,避免框架后续的字段取值逻辑覆盖你设置的空值
  • 如果不需要保留该列的占位,你也可以直接在RowSelected事件中把非BreakQty行的inventoryID字段Visible属性设为false,实现更彻底的隐藏。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.30 02:48:03