Passing list to a custom widget

0
Hello all,  I’ve build a custom widget that it’s input needs to be a list. For testing purpose I’ve selected the UserRole by xpath,  but when examining the props that passed to my component I don’t see any attributes available except the id.    Here is my xml: Here is what passed as props:   Fixed:   To use the values attribute need to be added into the xml,  for example:   property key="RoleName" type="attribute" required="true" dataSource="data"> <caption>Time Attribute</caption> <description /> <attributeTypes> <attributeType name="String"/> </attributeTypes> </property>   And to get the values of the attributes, you need to use the client api’s.    for example, const myItems = data.items.map(item=>{ return RoleName.get(item).value; })  
asked
1 answers
1

This is my xml property.

image.png

 

Step 1: Fetch items from props.datasource1 where datasource1 is my key.

const { items } = props.datasource1;

 

Step 2: Get list by using below syntax.

var listOfObjects = items.map(item => item[Object.getOwnPropertySymbols(item)[0]]._jsonData);

 

If you want print all attributes list then you can do this.

for (let i = 0; i < listOfObjects.length; i++) {

      console.log(listOfObjects[i].attributes)

 }

 

answered