Home Analytics Developing analytics applications
The community of Analytics developers are invited to follow and participate in the developer network.
OpenText technical experts collaborate with supported customers and partners in the Magellan product area.

formatting attributes dynamically

I need help.

I want change all atributes in beforeFactory or initialize

I have

#FF0000

Custom
(#0.00)

right
col01

I can change color,textAlign,resultSetColumn

elemento="Data04"
myLabelHandle = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement(elemento);

myLabelHandle.setStringProperty("resultSetColumn", "col02");
myLabelHandle.setStringProperty("color", "Red");
myLabelHandle.setStringProperty("textAlign", "left");

How can I change numberFormat/pattern ?

Antônio Carlos

Best Answer

  • Accepted Answer

    In the onCreate event of a label:
    this.text = Formatter.format(parseFloat(this.text), "$##,####.##");

    When formatting an element that has the Format Number property, set the format dynamically using:
    this.getStyle().numberFormat = "$##,####.##"

    Jeff F.
    Customer Support Engineer I
    OpenText

Answers

  • Accepted Answer

    In the onCreate event of a label:
    this.text = Formatter.format(parseFloat(this.text), "$##,####.##");

    When formatting an element that has the Format Number property, set the format dynamically using:
    this.getStyle().numberFormat = "$##,####.##"

    Jeff F.
    Customer Support Engineer I
    OpenText
  • I need help.
    I want change all atributes in beforeFactory or initialize
    I have

      <data name="Data04" id="1269">
                            <property name="color">#FF0000</property>
                            <structure name="numberFormat">
                               <property name="category">Custom</property>
                                <property name="pattern">(#0.00)</property>
                            </structure>
                            <property name="textAlign">right</property>
                            <property name="resultSetColumn">col01</property>
                        </data>
    

    I can change color,textAlign,resultSetColumn
    elemento="Data04"
    myLabelHandle = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement(elemento);
    myLabelHandle.setStringProperty("resultSetColumn", "col02");
    myLabelHandle.setStringProperty("color", "Red");
    myLabelHandle.setStringProperty("textAlign", "left");
    How can I change numberFormat/pattern ?
    Antônio Carlos

  • jfranken ,
    thanks.

    my request was to put parentheses and red color when the number is negative, what I did was

    I create a new style ("style_parentheses") with the format="(#,###.##)"
    and in beforeFactory I did

    myLabelHandle = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("Data04");
    hr = StructureFactory.createHighlightRule();

    hr.setTestExpression("row['col01']";);

    hr.setValue1(0);

    hr.setProperty("operator","lt");
    hr.setProperty("color","Red");
    hr.setProperty("style","style_parentheses");

    ph = myHandle.getPropertyHandle("highlightRules");
    ph.addItem(hr);

    Antonio Carlos

  • wwilliamswwilliams Junior Member

    Did you try selecting the element, then properties, then format number and choose (1,234.56) that would solve the parenthesis. Then choose the highlights tab and add a condition to make it red if it less than zero?

Sign In or Register to comment.