动态隐藏网格中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
相关产品推荐
相关产品推荐

