Get element by ID

adilb
edited February 11, 2022 in Analytics #1
Hi All,

I want to get a reference to a report element via its ID. In javascript that would be done via

document.getElementById("myElemenentId").text="mytext";

Is there anything similar in birt script?

Regards,

Adil

Comments

  • hq4ever
    edited December 31, 1969 #2
    <pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.getDesignHandle().getElementByID(201)</pre>
    <br />
    Read all about this here <a class='bbc_url' href='http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php'>Report Scripting</a>
  • adilb
    edited December 31, 1969 #3
    Thanks for the hint. But I still have problems making it work

    use the statement

    reportContext.getDesignHandle().getElementByID(609).text = "my text"

    but that didnt work. I suppose the element handle is obtained correctly but the text property is not set.

    Any more thoughts on this?

    Thanks,

    Adil
  • bluish
    edited December 31, 1969 #4
    Maybe you could try to wrap the id in double quotes. Let me know!
  • Rajesh kmr
    edited December 31, 1969 #5
    in which element you are writing this statement and in which method..please explain
  • kclark
    kclark E
    edited September 24, 2012 #6
    <blockquote class='ipsBlockquote' data-author="'adilb'" data-cid="52772" data-time="1251040935" data-date="23 August 2009 - 08:22 AM"><p>
    Hi All,<br />
    <br />
    <br />
    I want to get a reference to a report element via its ID. In javascript that would be done via <br />
    <br />
    <br />
    document.getElementById("myElemenentId").text="mytext";<br />
    <br />
    <br />
    Is there anything similar in birt script?<br />
    <br />
    <br />
    Regards,<br />
    <br />
    <br />
    Adil<br /></p></blockquote>
    <br />
    You can do this a few ways<br />
    <br />
    <pre class='_prettyXprint _lang-auto _linenums:0'>
    reportContext.getDesignHandle().findElement("myElementId").text = "test"
    </pre>
    <br />
    If you labeled it, if you know the ID number you can use the following<br />
    <br />
    <pre class='_prettyXprint _lang-auto _linenums:0'>
    reportContext.getDesignHandle().getElementByID(74).text = "Test"
    </pre>
    <br />
    Where 74 is the ID number
    Warning No formatter is installed for the format ipb
  • jain
    edited December 31, 1969 #7
    Hi,

    In my report I need to set the content in master page footer based on the element Id. I have three sections in my report and each section has table element and I must ensure that a section always starts on a new page (page break).
    Also the master page footer content varies for each section, so how do I change the content for each section in master page footer?

    section1(in page 1): Header(some logo)
    Table
    Footer ("some test for example: Test A")

    section2(in page 2): Header(some logo)
    Table
    Footer ("some test for example: Test B")

    section3(in page 3): Header(some logo)
    Table
    Footer ("some test for example: Test c")