フィルタ関数¶
[select / categorySelect] widgetsで使用するマスタを動的に変更する
フィルタ関数を設定することができます。
利用者の指定に応じて、選択肢を動的に変更する場合に使用します。
フィルタ関数のためのプロパティ¶
プロパティ | 内容 | 必須 | 備考 |
---|---|---|---|
filterFunc | フィルタ関数 | 必須 | |
watchItems | 変更を監視する項目のキー |
|
フィルタ関数の例¶
監視する項目名が、[monitorItem]で値が[01]とそれ以外で
選択肢を変更するためのフィルタ関数の例を示します。
import { FormGroup } from '@angular/forms';
function filterFunc(form: FormGroup) {
// 監視する項目
const monitorItemName = 'monitorItem';
if ( form.controls[monitorItemName].value === '01' ) {
return {[
{ 'key': 'selectTarget_01', 'value': '01' },
{ 'key': 'selectTarget_02', 'value': '02' },
{ 'key': 'selectTarget_03', 'value': '03' }
]}
}
return {[
{ 'key': 'selectTarget_04', 'value': '04' },
{ 'key': 'selectTarget_05', 'value': '05' }
]}
};
上記filterFunc関数を使用したselectのレイアウト例:
{
'type': 'select',
'master': 'selectMaster',
'key': 'selectItem',
'filterFunc': filterFunc,
'watchItems': 'monitorItem'
}