Pluggable Widget: How can I access attributes from a datasource list? Currently, they show up as undefined.
0
Hi, I am trying to create a pluggable widget that needs to receive a datasource list and then access its attribute values. In the xml’s file, I have something like this: <property key="data" type="datasource" isList="true" required="true"> <caption>Task list data source</caption> <description /> </property> <property key="taskID_" type="attribute" dataSource="data"> <caption>Task ID</caption> <description></description> <attributeTypes> <attributeType name="String"/> </attributeTypes> </property> (...) Where the first attribute is the list and the second, one if the list record’s attributes. After that, I am checking if the list is “available” and if so, I need to access its values. While debugging, I can see that the list has loaded and has 5 items: But all of the attributes show as undefined: Since the datasource is available, so should be its attributes, right? I have tried using the get method explained here, but with no success, as the object is undefined. Is there something I am doing wrong for the attributes to be undefined? Appreciate your help. Edit: Please see my latest attempt below. Was trying to get the data.items attributes and map them into a new object. Note that the attributes with _ are the ones I declared in the xml. file as attributes. Still get an undefined error: Cannot read properties of undefined (reading 'get'). export function GanttTaskReactComponent({data, taskID_, taskName_, displaytype_, start_, end_, progress_, depedencies_, isDisabled_, fontSize_, project_, hideChildren_, optionsJSON}) { return data.status === 'available' ? ( <Gantt tasks={data.items.map(previousTask => { const newTask = { id: taskID_.get(previousTask), name: taskName_.get(previousTask), type: displaytype_.get(previousTask), start: start_.get(previousTask), end: end_.get(previousTask), progress: progress_.get(previousTask), depedencies: depedencies_.get(previousTask), isDisabled: isDisabled_.get(previousTask), fontSize: fontSize_.get(previousTask), project: project_.get(previousTask), hideChildren: hideChildren_.get(previousTask) }; return newTask; })}/> ) : ( <div>Loading...</div> ); }
asked
João Lopes
1 answers
0
Not sure what the error was, but after starting a new widget from scratch, this time in typescript, was able to make it work. The final version looks something like this: