根据调用方法的位置返回对窗体或窗体上的项的引用。
Syntax
ExecutionContextObj.getFormContext()
返回值
类型:对象
说明:返回对窗体或窗体上的项的引用,例如可编辑网格,具体取决于调用方法的位置。 使用此方法,可以创建可在窗体上作的常见事件处理程序,或窗体上的项,具体取决于窗体的调用位置。
Example
以下示例代码演示如何创建一个方法,根据注册脚本的位置(Column OnChange 事件或可编辑网格 OnChange 事件)在窗体列或可编辑网格单元格上设置通知的方法:
function commonEventHandler(executionContext) {
var formContext = executionContext.getFormContext();
var telephoneAttr = formContext.data.entity.attributes.get('telephone1');
var isNumberWithCountryCode = telephoneAttr.getValue().substring(0,1) === '+';
// telephoneField will be a form control if invoked from a form OnChange event;
// telephoneField will be a editable grid GridCell object if invoked from editable grid OnChange event.
var telephoneField = telephoneAttr.controls.get(0);
if (!isNumberWithCountryCode) {
telephoneField.setNotification('Please include the country code beginning with '+'.', 'countryCodeNotification');
}
else {
telephoneField.clearNotification('countryCodeNotification');
}
}