How to set value for attribute type Integer in pluggable widget?

0
I’m using plain Javascript to write a pluggable widget that can change the value of an integer attribute. But I keep getting : Error: Value 0 is not assignable to attribute of type Integer.     at r (mxui.js?637639250406972942:73)     at b (mxui.js?637639250406972942:73)     at v (mxui.js?637639250406972942:73)     at P (mxui.js?637639250406972942:73) Here is my .xml: <propertyGroup caption="Data source"> <property key="intAttr" type="attribute"> <caption>Attribute</caption> <description/> <attributeTypes> <attributeType name="Integer"/> </attributeTypes> </property> </propertyGroup> My code: <input type="text" className={classNames("form-control", props.className)} value={value} onChange={(event) => { props.intAttr.setValue(parseInt(event.target.value)) }} /> I’m writing in functional React component so there is no “this” before “props”. I have followed the tutorial from Build a Pluggable Widget but it’s not working in this case. So what is the correct way to set the value in Javascript ES6?
asked
2 answers
1

You can also use this:
 

props.intAttr.setTextValue("" + someIntValue)

A bit crude but works perfectly.

answered
1

This is about (expected) data types.

You’re using setValue(), but there’s also a setNumber().

answered