views:

3153

answers:

2

I am building my first report in BIRT.

Very quickly I ran into a problem in which I wanted to display some text or data based on an expression that included data from two different tables (not tables that can/should be joined - (hypothetically example- take a student's ACT score from his record in the student table and compare it against the statistics table's entry for ACT statistics). I soon realized that a data element has to be bound to a dataset (only one of them.)

I found a similar question in the BIRT mailing list which helped me get to a solution - I can bind an individual data element to a different dataset, but it can still access the elements of its container. I can send a parameters to the dataset that the element is bound to (e.g. "ACT" in the example I mentioned above).

Eventually however, I came to a place where I needed to use data from three different tables. I am stuck here, and I'm assuming that there is a way to do this through the scripting abilities, but I have yet to see in the documentation a way to extract data from a data set - everything I have dealt with so far is associated with binding a report element to a dataset.

To be clear, I have seen that I can add JavaScript functions to the initialize section of the top level report (and call them from an expression in a data element) but I don't see how in a script I can query any of my datasets -- as opposed to only interacting with the dataset bound to my data element).

How can I access an arbitrary (though already defined) data set from JavaScript in BIRT? (Or how can I access more than two datasets from an element - one that it is bound to, and one that its container is bound to?)

+1  A: 

I have not tried to do this for a while. The immediate answer that pops to mind is that you need to put the third data set into a table (can have visibility set to false) and you would need to populate the table values to a GlobalValue. Then you could get at the GlobalValues from the data control through script.

I know that it is not pretty. I will have a look over the weekend and see if 2.3 has added any functionality that makes this easier.

Scott Rosenbaum
I wondered if I could do something like that (bind an element to the datum I need, make it invisible) - but I thought that surely with all the scripting capabilities that seem to exist, there must be a better way! I would appreciate hearing anything you learn.
pc1oad1etter
If that does end up being the route, is there going to be a way to easily "query" the table to get the cell I want? This table could be pretty large so I don't know if this will actually be a solution.
pc1oad1etter
A: 

I have a simillar problem! I need to access a data set value in java script. The data set is never displayed on the BIRT report. The code looks like this

this.text=dataSetRow["RUN"];

I have done the binding in the binding editor.

I am getting the following error!! org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script "this.text = dataSetRow["RUN"];":

ReferenceError: "dataSetRow" is not defined. (/report/body/grid[@id="32"]/row[@id="36"]/cell[@id="37"]/label[@id="261"]/method[@name="onPrepare"]#8) at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1166) at org.eclipse.birt.report.engine.api.impl.ScriptedDesignHandler.handleOnPrepare(ScriptedDesignHandler.java:124) at org.eclipse.birt.report.engine.api.impl.ScriptedDesignVisitor.visitLabel(ScriptedDesignVisitor.java:270)

Any help will be appreciated. Thanks

Prasanna Tatti
Unrelated to OP, your problem is you are not using correct syntax. Try this.text=row["RUN"];
Maxim Veksler