Implementing HandsOnTable as a custom mendix widget - how to update attributes

0
Hi Mendix community,    I'm evaluating Mendix for a customer project and one of the key needs is to show a table of data in a HandsOnTable format. At this point: I have a working custom pluggable widget using react and typescript I'm able to populate a list of entity with all relevant attributes showing as needed.  I used a datasource and listvalue list/attribute value.   HandsOnTable has an excel like interface and allows users to edit the data they see fairly efficiently.  Once the cell is updated it fires a callback js function.   My next task, where I need help is how can I communicate back with Mendix platform to update the correct attribute / entity? I just saw this scary note: I hope someone can help. As I understand it to show data from a list of entities I have to use ListValue and ListAttributeValue, but now I don't seem to have a way to update these attributes. Please help!
asked
1 answers
1
<property key="datasource" type="datasource" isList="true" required="false">
       <caption>Data Source</caption>
       <description/>
</property>

 

If you using this xml code for get list. Then you can use below code to update/change mendix object attribute values.

 

useEffect(() => {       
 try { 
      // Get List of Mendix Objects
      const {items } = props.datasource;
      let listOfMxObjects = items.map(item => item[Object.getOwnPropertySymbols(item)[0]]);

       // Update List of Mendix Objects
       for (let i = 0; i < listOfObjects.length; i++) {
              listOfMxObjects[i].set('ImageWidth',100)
              listOfMxObjects[i].set('ImageHeight',200)
           }
        } catch (e) {
            console.log("error", e);
        }
}, [props])

 

Hope this will help you.

Thanks

answered