How to access or hide rows and getcolumn name in a table using actuate birt javascript api

1.3k Views Asked by At

Below example is to get rows or column names. I want to hide column names by indexing only and not by column name.Is it possible to get column name by indexing using table element? I also want to hide rows based on indexing. Please provide solution?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
  <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  <title>Viewer Page</title>
</head>

<body onload="init()">
  <script type="text/javascript" language="JavaScript" src="http://localhost:8700/iportal/jsapi"></script>
  <script type="text/javascript" language="JavaScript">
  function init() {
    actuate.load("viewer");
    actuate.load("dialog");
    actuate.initialize("http://localhost:8700/iportal", null, "administrator", null, runReport);
  }

  function runReport() {
    var viewer = new actuate.Viewer("viewerpane");
    var manUIOptions = new actuate.viewer.UIOptions();
    manUIOptions.enableToolBar(false);
    manUIOptions.enableFilter(true);
    viewer.setUIOptions(manUIOptions);
    viewer.setReportName("/Resources/xyz.rptdesign");
    viewer.submit(getColumnAndHide);
  }
  callBackError = function(exception) {
    window.alert('ERROR: ' + exception);
  };

  function getColumnAndHide(viewer) {
    var myTable = viewer.getCurrentPageContent().getTableByBookmark("detail");
    //var myColumn=myTable.getColumnName(2);
    //myTable.getRow(2);
    myTable.submit();
  }
  </script>
  <div id="viewerpane"></div>
</body>

</html>
1

There are 1 best solutions below

0
Semo On

Here's an overview for you. First I would "configure" all inside the birt report, which shall be hidden or not. It's a bad design in my opinion, if the report is manipulated while using it. It could lead to serious race conditions, wrong outcomes and difficult debugging problems. The basics of creating a birt report are pretty much wrapped up here: Vogel, "Reporting with Eclipse BIRT and Java Objects (POJO’s) - Tutorial"

Then, when you have a Dataset or let's say a kind of data container like a variable you can put the content into your Template (*.rptdesign file).

The workflow is as follows:

  • Put a Grid into the page
  • put a label or datacell or whatever can contain variable text into the grid
  • Select the element via point-and-click™
  • In the "Property Editor", there is a Visibility-Tab to click.
  • Enter the correct expression (e.g. JS), Save and Run a Test.

Simple example screenshot

If you like I made a simple example to show you how to hide an element, if a requirement is met. You can download it. BIRT Report Design Example

It's free GNUv2 whatever... Hope this helps you a bit. AFAIK