How to read values from ObjectItem object?

0
I am looping to a ListValue/ObjectItem-array in a pluggable widget and get individual ObjectItem-object.   In those objects the values I need are captured in the JsonData-attribute, as shown in the screenshot below.   How to get to those values? I have tried several suggestions already, but none seem to give the value of that jsonData-aatribute.    
asked
2 answers
1

If you want to interact with the attributes of a datasource (e.g. filtering or sorting) you need to provide an attribute in the XML so that the system knows the context with what attribute you want to work with.

 

ObjectItems does not provide you direct access to any data attributes.

 

You can then use the ListAttributeValue to get the attribute value of an object as specified in the docs.

 

Below you can find an example:

</property>
<property key="itemsAll" type="datasource" isList="true" required="true">
    <caption>Datasource</caption>
    <description></description>
</property>
<property key="enumeration" type="attribute" dataSource="itemsAll"
    required="false">
    <caption>Columns</caption>
    <description></description>
    <attributeTypes>
        <attributeType name="Enum" />
    </attributeTypes>
</property>
export default function Sample({enumeration, itemsAll} : SampleProps) : void {
    const attributeValueOfFirstObject = enumeration?.get(itemsAll.items![0])
}

 

answered
0

That is the direction I found the answer as well eventually.:

 

//myCollection is the the ListValue collection
const items = myCollection.items;

if (items) {
    list = items.map((item: any) => item[Object.getOwnPropertySymbols(item)[0]].jsonData.attributes);
    // rest of code
}

 

answered