getInheritedProps()
Obtains the properties that are set in the parent metadata node within the inheritedProps metadata structure. The inheritedProps metadata allows cascading of values in the view metadata, which results in better reuse of the properties.
Returns
The inherited properties as an object.
Parameters
This API does not have parameters.
Usage example
In this example, the API obtains the value of the label property inherited from the
parent metadata and overrides the value of the label
property set in the
child view.
// Parent reference metadata
{
"type": "reference",
"config": {
"name": "Address",
"inheritedProps": [
{
"prop": "label",
"value": "@L Shipping address"
}
]
}
}
// Child reusable Address view
{
"name": "Address",
"type": "View",
"config": {
"template": "OneColumn",
"ruleClass": "Data-Address"
"label": "Generic address"
},
"children": [
{
"name": "A",
"type": "Region",
"children": []
}
]
}
// During rendering the Address child view, you can retrieve the inherited label as follows:
const propsToUse = { label, ...getPConnect().getInheritedProps() };
// This results in propsToUse.label being assigned the “Shipping address” value. This inherits the value that was set on the parent (if the parent had a “label” property) and overrides any “label” property that was set on the child view.
Previous topic getImagePath(imageName) Next topic getLocaleRuleName()