问题描述
我们在表单中的可编辑子网格上使用this snippet,而其中一个属性触发onchange
事件触发了此功能,到目前为止,必需字段已标记为必需。因此,用户无法保存可编辑的子网格行,并且自动保存还会被通知消息阻止。
尽管onchange
函数将该字段标记为必填字段,但突然停止了调试,并且在调试时没有错误或异常-仍然,用户仍可以保存该记录而无需在必填字段中添加任何值。不知道为什么现在观察到这种行为改变。
还有其他人遇到此问题以及解决方法吗?
function ReasonChange(eContext) {
debugger;
// get the attribute which fired the onchange.
var reasonAttr = eContext.getEventSource();
// get the container for the attribute.
var attrParent = reasonAttr.getParent();
// get the value of the reason.
var reason = reasonAttr.getValue();
if (reason != null) {
// var field1 Attribute
var field1 = attrParent.attributes.get("new_followupdate");
//Callback
if (reason[0].id == "{33E9E459-5A8B-EA11-A812-000D3A5A17E3}") {
// set field as mandatory.
field1.setrequiredLevel("required");
}
else {
//clear field value
field1.setValue(null);
// set field as mandatory.
field1.setrequiredLevel("none");
}
}
解决方法
我现在可以想到的一种解决方法是在Onsave事件上添加代码,并检查字段值是否包含数据(如果未显示错误消息)。
还,您是否在其他浏览器中检查了行为是相同还是不同?
如果我有帮助,请标记我的回答