Custom Native Widget data source access problem

I am using data source property in xml for creating custom native widget. How can access values of that data source source (my list is of domain model I want properties values) in typescript code. Didn’t found any solution o  forum.  I want to access entities from list value with their properties values. Suppose I have list of Student entities need student name, age value in typescript code. /** * This file was generated from NativeCustomCalendar.xml * WARNING: All changes made to this file will be overwritten * @author Mendix UI Content Team */ import { ListValue } from "mendix"; export interface NativeCustomCalendarProps<Style> { name: string; style: Style[]; datasource: ListValue; } export interface NativeCustomCalendarPreviewProps { class: string; style: string; datasource: {} | null; }  
1 answers

You should add extra properties of the type “attribute” to your XML. They should have the datasource property set pointing to your data source. Here’s an example from Data Grid 2:


<property key="datasource" type="datasource" isList="true">
    <caption>Data source</caption>

<property key="attribute" type="attribute" dataSource="../datasource" required="false">
    <description>Attribute is required if the column can be sorted or filtered</description>
        <attributeType name="String"/>

In this configuration, attribute will be a ListAttributeValue. The link explains it more, but the code you would need in this example is like:

const attributeValue = this.props.attribute.get(this.props.datasource.items[0]);