How to pass list to custom widget / how to create custom list widget?

0
How do I need to configure the widget.xml to get a data source configuration – just as the list view, for example – so that the custom widgets receives the list of Entities? I tried something like <property key="entity" type="entity" isPath="optional" pathType="reference" allowNonPersistableEntities="true" required="false"> <caption>Data</caption> <category>Data source</category> <description>List</description> </property> but I cannot select children entities when the custom widget itself is in a data view:   What I want is to have the same options as the standard list view: Ideally, I would have the same options “Database”, “XPath”, … with the same functionality. I found no examples and documentation to solve this requirement. Any hints or ideas? I am using pluggable widgets and Studio Pro 8 beta 2.
asked
1 answers
1

 

Hi Martin,

This can be achieved but won’t look exactly the same as a datagrid/listview/templategrid. There are two options on how to do this. The first option, is to use a microflow to retrieve and return your data. The second option is to define the entity type and any xpath constraints that need to be applied.

A good example on how to do both of these option is the autocomplete widget

https://github.com/AuraQ/AutoCompleteForMendix/tree/master/src

 

Here is how your .xml file could look like for both options:

 

First option (microflow):

Define the entity type

<property key="dataAssociation" type="entity" required="true" isPath="yes" pathType="reference" allowNonPersistableEntities="true">
            <caption>Entity Type</caption>
            <category>Search</category>
            <description> </description> 
</property>

 

Define the microflow and return type

<property key="searchMicroflow" type="microflow" required="false">
            <caption>Search microflow</caption>
            <category>Search - Microflow</category>
            <description>Run this microflow to execute the search</description>
            <returnType type="Object" isList="true" entityProperty="dataAssociation"/>
</property>

 

 

Second Option (xpath):

Define the entity type

 

<property key="dataAssociation" type="entity" required="true" isPath="yes" pathType="reference" allowNonPersistableEntities="true">
            <caption>Entity Type</caption>
            <category>Search</category>
            <description> </description> 
</property>

 

Define the xpath constraint

<property key="dataConstraint" type="entityConstraint" required="false" entityProperty="dataAssociation">
            <caption>Data constraint</caption>
            <category>Search</category>
            <description></description>
</property> 

 

Then I would look at the client api documentation to see how to execute a microflow and retrieve using xpath in JS.

https://apidocs.mendix.com/8/client/

Hope this helps!

answered