Dynamically controlling visibility

evgenyak
edited February 11, 2022 in Analytics #1
Hello,

I have reports with a table and a chart.
Chart is hidden by default in "HTML" output because I'm using some flash based component.

However, in some cases, even in HTML, I would like to be able to display the chart.
Is it possible to control it dynamically from JavaScript of the rendering engine?

Thanks,

Comments

  • evgenyak
    edited December 31, 1969 #2
    Hello,

    I have reports with a table and a chart.
    Chart is hidden by default in "HTML" output because I'm using some flash based component.

    However, in some cases, even in HTML, I would like to be able to display the chart.
    Is it possible to control it dynamically from JavaScript of the rendering engine?

    Thanks,
  • mwilliams
    edited December 31, 1969 #3
    How do you decide if you'll hide the chart or not? A parameter?
    Warning No formatter is installed for the format ipb
  • evgenyak
    edited December 31, 1969 #4
    <blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="94550" data-time="1327358118" data-date="23 January 2012 - 03:35 PM"><p>
    How do you decide if you'll hide the chart or not? A parameter?<br /></p></blockquote>
    <br />
    Currently, it should be determined by Java code.<br />
    <br />
    By default, chart is hidden in the design file.<br />
    In Java code, sometimes, I want to "unhide" it.<br />
    However I wasn't able to do it :unsure:
  • mwilliams
    edited January 26, 2012 #5
    I mean, what tells you when you need to hide it? If you know early enough, you can just drop the chart from your design based on a certain criteria. Then, when you re-run the report again, the criteria would be different and the chart may be retained. Another possibility would be, using the visibility setting on the chart. You can use an expression for the HTML visibility. You can check your condition on whether to show it or not in the expression for the chart.
    Warning No formatter is installed for the format ipb
  • evgenyak
    edited December 31, 1969 #6
    I'm trying to remove the chart after "run" task but before "render". And it doesn't seem to work.<br />
    <br />
    <pre class='_prettyXprint _lang-auto _linenums:0'>
    IReportDocument rptdoc = m_ReportEngine.openReportDocument(reportName);

    ReportDesignHandle designHandle = rptdoc.getReportDesign();
    DesignElementHandle delm = designHandle.findElement("CHART");
    if (delm != null) {
    HideRule hideRule = org.eclipse.birt.report.model.api.StructureFactory.createHideRule();
    hideRule.setFormat("html");
    hideRule.setExpression("false;");
    PropertyHandle propHandle = delm.getPropertyHandle("visibility");
    if (propHandle.getItems().size() > 0) {
    // Here I remove hide rule which already exists in the design file
    propHandle.removeItem(0);
    }
    propHandle.addItem(hideRule); // Here, I add new "unhide" rule
    }

    </pre>
    <br />
    However, the chart does not appear - meaning that I wasn't able to alter the hide rule
  • mwilliams
    edited December 31, 1969 #7
    I guess I'm still not sure how you decide if you're going to hide it or show it in HTML. If I can understand that, maybe I'll be able to help further. Is it when the user decides or is it determined by some other factor. Please let me know.

    Thanks!
    Warning No formatter is installed for the format ipb
  • evgenyak
    edited December 31, 1969 #8
    <blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="94646" data-time="1327610346" data-date="26 January 2012 - 01:39 PM"><p>
    I guess I'm still not sure how you decide if you're going to hide it or show it in HTML. If I can understand that, maybe I'll be able to help further. Is it when the user decides or is it determined by some other factor. Please let me know.<br />
    <br />
    Thanks!<br /></p></blockquote>
    <br />
    It's very simple. I have two JSPs which are responsible to display the report.<br />
    <br />
    1st JSP is doing report preparation and rendering. And it also handles different report parameters.<br />
    This JSP should display the report without the chart.<br />
    <br />
    2nd JSP is for printing only. And it should display the chart as well.<br />
    Since, it's just a printout version of the report, I wanted to reuse the report file generated by the 1st<br />
    JSP (already with all the parameters inside set) and just to re-render it.<br />
    <br />
    Is it more clear now?<br />
    <br />
    Thanks!
  • mwilliams
    edited December 31, 1969 #9
    If you add a bookmark to your chart, say, "myChart". You could use html script tags in a text box to decide whether to show the chart in HTML or not, with something like:

    <script>
    if (your condition to hide the chart == true){
    document.getElementById("myChart").style.display = "none";
    }
    else{
    document.getElementById("myChart").style.display = "block";
    }
    </script>

    Then, just don't use the "visibility" property in BIRT and decide in your HTML to show or not.

    Will that work for your situation?
    Warning No formatter is installed for the format ipb
  • evgenyak
    edited December 31, 1969 #10
    <blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="94764" data-time="1327957375" data-date="30 January 2012 - 02:02 PM"><p>
    If you add a bookmark to your chart, say, "myChart". You could use html script tags in a text box to decide whether to show the chart in HTML or not, with something like:<br />
    <br />
    <script><br />
    if (your condition to hide the chart == true){<br />
    document.getElementById("myChart").style.display = "none";<br />
    }<br />
    else{<br />
    document.getElementById("myChart").style.display = "block";<br />
    }<br />
    </script><br />
    <br />
    Then, just don't use the "visibility" property in BIRT and decide in your HTML to show or not.<br />
    <br />
    Will that work for your situation?<br /></p></blockquote>
    <br />
    Thanks! I'll give it a try.<br />
    How can I control the "ID" of the chart element?<br />
    The ID of the chart in the design file is "CHART" but I don't see it in the HTML.<br />
    <br />
    Thanks
  • evgenyak
    edited December 31, 1969 #11
    <blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="94764" data-time="1327957375" data-date="30 January 2012 - 02:02 PM"><p>
    If you add a bookmark to your chart, say, "myChart". You could use html script tags in a text box to decide whether to show the chart in HTML or not, with something like:<br />
    <br />
    <script><br />
    if (your condition to hide the chart == true){<br />
    document.getElementById("myChart").style.display = "none";<br />
    }<br />
    else{<br />
    document.getElementById("myChart").style.display = "block";<br />
    }<br />
    </script><br />
    <br />
    Then, just don't use the "visibility" property in BIRT and decide in your HTML to show or not.<br />
    <br />
    Will that work for your situation?<br /></p></blockquote>
    <br />
    I think it helped!!!<br />
    Thanks a lot, I'll keep you posted
  • mwilliams
    edited December 31, 1969 #12
    I'm assuming you got that the Id is the bookmark value that you set. Let me know!
    Warning No formatter is installed for the format ipb
  • evgenyak
    edited December 31, 1969 #13
    <blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="94803" data-time="1328025570" data-date="31 January 2012 - 08:59 AM"><p>
    I'm assuming you got that the Id is the bookmark value that you set. Let me know!<br /></p></blockquote>
    <br />
    Yeah ! It helped, thanks a lot!
  • mwilliams
    edited December 31, 1969 #14
    You're welcome. Let us know whenever you have questions! :)
    Warning No formatter is installed for the format ipb
  • SureshMart
    edited July 3, 2012 #15
    Hi Michael,

    Can you please help me knowing if there is anyway we can hide a particular row on the onrender event?

    On the onRender method of the Group section and detail section, i wrote the below code. This although hides the data but it generates unnecessary extra pages. Other issue is when it exported to pdf the TOC displays other data as well.


    var row = this.getRowData().getColumnValue("SalesRep");

    if (row != user && user != "Administrator")
    this.getStyle().display="none";


    Can you please help me on this? Thanks
  • CBR
    CBR
    edited December 31, 1969 #16
    Hi Suresh,

    therefore use visibility of element by selecting the particular row and going to visibility tab in the property editor. Add rule like:

    (row != user && user != "Administrator")

    This will hide the row if both conditions are true.
  • SureshMart
    edited July 6, 2012 #17
    <blockquote class='ipsBlockquote' data-author="'cbrell'" data-cid="106900" data-time="1341338412" data-date="03 July 2012 - 11:00 AM"><p>
    Hi Suresh,<br />
    <br />
    therefore use visibility of element by selecting the particular row and going to visibility tab in the property editor. Add rule like:<br />
    <br />
    (row != user && user != "Administrator")<br />
    <br />
    This will hide the row if both conditions are true.<br /></p></blockquote>
    <br />
    <br />
    Hi cbrell,<br />
    <br />
    I hope my question wasn't clear. The report will be running in batch mode by Administrator, the output will be saved for all the Users to view it. When each user login they will be able to see there own data. This is similar to Page Level Security of Actuate BIRT. That's why I was using the OnRender event to hide it. While the creation of the report all the data should be created but while viewing the Data to which that User is authorized can only view the data.<br />
    <br />
    If I put the same code in the Visibility property, it will show all the data while creating the file by Administrator, which is correct. But When Individual Users are viewing Visibility Property willn't be called, so it will display all the rows.<br />
    <br />
    Note: We dont have the Page Level Security License... So was trying if it could be possible without the license by any sort of coding.
  • Hi Michel, and Suresh,
    Did you achieved PDF/HTML visibility control dynamically using client script?
    I have similar requirement; I create n no of charts dynamically and default PDF visibility is off; I want to  control those chart visibility depends on some selection on same report!
    display style none -> inline will work but I dont want to use it because it cant control whether generated PDF export holds such chart or not
    I need to decide Exported PDF content can holds chart are not by visibility style setting at client side?

    please see attached example of toggling pdf visibility which is not working but display style is working