how to use getProperty in schema-form in Angular?

167 views Asked by At
public static get schema(): ISchemaModel {
    const schema = {
      formTitle: 'process-stream-parameter',
      type: 'object',
      readOnly: false,
      properties: {
        name: {
          type: 'string',
          description: 'gl.process-stream-parameter.schema.name',
          widget: '_string',
        },
        processStreamCategoryId: {
          type: 'object',
          description: 'gl.process-stream-parameter.schema.processStreamCategoryId',
          serviceName: 'processStreamCategoryListService',
          widget: '_select',
          help: 'gl.process-stream-parameter.schema.help.processStreamCategoryId',
          titleKey: 'name',
          properties: {
            id: {
              type: 'number'
            },
            title: {
              type: 'string'
            },
            _title: {
              type: 'string'
            }
          }
        },
        unitGroupSelective: {
          type: 'string',
          description: '',
          widget: '_empty',
        },
        unitId: {
          type: 'object',
          description: 'gl.attribute.schema.unitId',
          widget: '_couple-autocomplete',
          properties: {
            id: {
              type: 'number'
            },
            title: {
              type: 'string'
            },
            _title: {
              type: 'string'
            }
          },
          primitiveAutocomplete: {
            serviceName: 'unitGroupListService',
            help: 'gl.attribute.schema.unitGroup',
            description: 'gl.attribute.schema.unitGroup',
            fieldName: 'unitGroupSelective',
            foreignKey: 'title',
            params: {
              titleKey: 'title'
            },
            properties: {
              id: {
                type: 'number'
              },
              title: {
                type: 'string'
              },
              _title: {
                type: 'string'
              }
            },
          },
          associateAutocomplete: {
            serviceName: 'unitListService',
            help: 'gl.attribute.schema.unitId',
            description: 'gl.attribute.schema.unitId',
            fieldName: 'unitSelective',
            methodName: 'units',
            params: {
              titleKey: 'title'
            },
            properties: {
              id: {
                type: 'number'
              },
              title: {
                type: 'string'
              },
              _title: {
                type: 'string'
              }
            },
          }
        },
      },
      required: ['name']
    } as ISchemaModel;
    return schema;
  }

here is my code to get the schema property: I want to get primitiveAutocomplete and associateAutocomplete that are in unitId in my widget:

 console.log(this.formProperty.findRoot().getProperty('associateAutocomplete'));

both returns undefined, but when I write this:

console.log(this.formProperty.findRoot().getProperty('unitId'));

it returns its property

what should I do?

1

There are 1 answers

0
JBA On

you can use it :

this.formProperty.findRoot().getProperty('unitId').properties['your prop'].value

or use this method:

searchProperty('your prop')