Pluggable widgets -> Access associated data of an entity using client API

1
Hi, I have developed a pluggable widget with property type as ‘datasource’. Widget is  accepts entity object as input and using this input object I want to access the associated data through association and its attributes inside the widget using client API.  ObjectItem that represents input object gives only ID. Any suggestions on retrieving input object’s associated data inside the widget? Below is the sample Widget definition XML <property key="data" type="datasource" isList="true" required="false"> <caption>Data source</caption> <description /> </property> I tried using it with widget type property. But I am not sure how to retrieve data over association
asked
4 answers
1

Hi Mohan,

The pluggable widget API does not have documented support for data source attributes yet. The feature is in the making. Already some widgets in the Mendix repository are using it. The first variant will be read-only and can not be used to write. Nothing is officially released. And hope they will finish up and release this feature soon.

https://github.com/mendix/widgets-resources/blob/master/packages-web/maps/src/Maps.xml#L80

https://github.com/mendix/widgets-resources/blob/master/packages-web/maps/src/utils/data.ts#L20

https://github.com/mendix/widgets-resources/blob/master/packages-web/maps/src/utils/data.ts#L31

Cheers, Andries

 

answered
0
mx.data.get({
    guid: "123456",
    callback: function(obj) {
        console.log("Received MxObject with GUID " + obj.getGuid());
    }
});

 

https://apidocs.rnd.mendix.com/8/client/mx.data.html

answered
0

Andries Smit,

Documentation says we can retrieve data over association using widgets property type.

I followed the approach described in documentation and created Widget definition xml as below 

<propertyGroup caption="Data source">
            <property key="data" type="datasource" isList="true" required="false">
                <caption>Data source</caption>
                <description />
            </property>
            <property key="widgetContent" type="widgets" required="false" dataSource="data">
                <caption>Content</caption>
                <description>Widgets using data source</description>
            </property>
        </propertyGroup>

Code to process this data is as below

objItems.map(i => {
                    if(this.props.widgetContent!==null && this.props.widgetContent!==undefined){
                        let content:ReactNode  = this.props.widgetContent(i);
                        console.log(content);
                        
                        /* Retrieve child data over association from above 'content' variable */
                    }
                });

I am passing only parent entity data to widget and as mentioned above I need to retrieve child data over association from widget input data. 

answered
0

Hi Mohan, 

were you able to sort this out? I have the same challenge in one of my widgets currently.

answered