Anonymous_User Absent Member.
Absent Member.
616 views

Layout and element properties


Hello

There is a need to add (sum) properties of two different elements (elA
and elB for example) in Layout. As shown in documentation, one text tag
supports only one element for binding.
Is there any solution for summarize a few elements?

Thanks,
Yakov


--
Keranchuk
------------------------------------------------------------------------
Keranchuk's Profile: https://forums.netiq.com/member.php?userid=3828
View this thread: https://forums.netiq.com/showthread.php?t=46562

Labels (1)
0 Likes
3 Replies
Anonymous_User Absent Member.
Absent Member.

Re: Layout and element properties


Off the top of my head, two options.

Option 1: If you are under the Service Model (IE: not an element under
an adapter), you can create a meta-model property page. You add a
property to the element that is a Computed Field. For the computed
field, you add the script to do the math in javascript form.

Add Property, name it, hit next, on drop down change "Text" to Computed
Field. In the drop down below that which is empty, choose "Script
Expression". In the box below that, type in the script. Since you are
just doing a simple math calculation, just do...

element.prop1 + element.prop2

This will add a new property that automatically calculates the result
and provides a read-only property on the element. From there, just use
that property in the SVG layout like you normally would.

Option 2: This option is to do the calculation on the fly within the
SVG. Add a text item to the drawing or nodestyle. Right-click on the
Text item, Choose Customize, Add Binding, VALUE.

The dialog that comes up allows three options, choose FormulaScript. In
the box below, do...

element.prop1 + element.prop2


Please let us know your results. Thanks.


--
tisenberg
------------------------------------------------------------------------
tisenberg's Profile: https://forums.netiq.com/member.php?userid=1851
View this thread: https://forums.netiq.com/showthread.php?t=46562

0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Layout and element properties


Hello, thanks for your response
I mean 2 different elements,
it works this way:

<svg ...>
<text ...>
<bind:value>
<![CDATA[
var a = formula.Root.findElement('dname1')
var b = formula.Root.findElement('dname2')

var aa = java.lang.Integer.parseInt(a['counter']) //if do not use
parseInt property will be string
var bb = java.lang.Integer.parseInt(b['counter'])

var sum = aa +bb

sum // not obvious thing, magic. Finally display binding value
</bind:value>
</text>
</svg>


--
Keranchuk
------------------------------------------------------------------------
Keranchuk's Profile: https://forums.netiq.com/member.php?userid=3828
View this thread: https://forums.netiq.com/showthread.php?t=46562

0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Layout and element properties


yes, that is the way it works, the last line must return a result.
Computed properties work the same. The following below represent single
line examples you can do...

(aa +bb)

or

(sum)

or

( ((a*b)+7)/2 )

or

( element.property )

or

etc,etc,etc

I usually put () around them to make it appear more like a logic line
than random text sitting at the end of a script 🙂


--
tisenberg
------------------------------------------------------------------------
tisenberg's Profile: https://forums.netiq.com/member.php?userid=1851
View this thread: https://forums.netiq.com/showthread.php?t=46562

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.