다음을 통해 공유


getFormContext(클라이언트 API 참조)

메서드가 호출된 위치에 따라 폼이나 폼의 항목에 대한 참조를 반환합니다.

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');
    }
}

실행 컨텍스트
양식 컨텍스트