view イベント・ハンドラー

この view 関数は、ユーザーがビューを表示できるようになる前に、ビューにデータを取り込むなどのロジックを実行します。

使用法

view 関数を使用して、ビューがレンダリングされる前のロジックを実行します。 例えば、可視性の設定に応じて、ラベルを表示したり非表示にしたりできます。

パラメーター

view 関数はパラメーターを取りません。

ビューに可視性が設定されていない場合は、デフォルトで親の可視性が継承されます。 view() メソッドのデフォルト・ロジックに加えて独自のビュー・ロジックを使用する場合は、構文 this.constructor.prototype.view.call(this); を使用して、 view() 関数内でスーパークラス・ビュー・ロジックを呼び出すことができます。

サンプル

view() 関数の以下のコードでは、出力テキスト・コントロールの可視性プロパティーの設定を検査し、プロパティーの値に基づいて表示を true または false に設定します。 ビューに可視性が設定されていない場合は、親の可視性が継承されます。
var labelDiv = this.context.element.querySelector(".outputTextLabel");

if (this.context.options._metadata.label == undefined ||
    this.context.options._metadata.label.get("value") == "" ||
    (this.context.options._metadata.labelVisibility != undefined &&
     this.context.options._metadata.labelVisibility.get("value") == "NONE")) {
	// hide the label div
	this.context.setDisplay(false, labelDiv);
} else {
	// show the label div
	this.context.setDisplay(true, labelDiv);
}