在BIRT中,如何从JavaScript访问任意数据集?

时间:2022-01-07 02:34:14

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).

我在BIRT邮件列表中发现了一个类似的问题,它帮助我找到了一个解决方案——我可以将一个单独的数据元素绑定到一个不同的数据集,但是它仍然可以访问它的容器的元素。我可以向元素绑定到的数据集发送一个参数(例如。在上面我提到的例子中“ACT”)。

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).

需要澄清的是,我已经看到,我可以添加JavaScript函数的初始化部分*报告从一个表达式(称之为数据元素)但我不明白如何在脚本中我可以查询任何数据集,而不是只与数据集绑定到我的数据交互元素)。

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?)

如何从BIRT的JavaScript中访问一个任意(虽然已经定义)的数据集?(或者如何从一个元素访问两个以上的数据集——一个是它绑定的,另一个是它的容器绑定的?)

2 个解决方案

#1


2  

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.

我已经有一段时间没试过这么做了。突然想到的答案是,您需要将第三个数据集放到一个表中(可以将可见性设置为false),并且您需要将表值填充到一个GlobalValue中。然后您可以通过脚本从数据控件获取全局值。

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.

我知道它不漂亮。我将在周末查看一下,看看2.3是否添加了任何使这一过程更容易的功能。

#2


1  

Use the

使用

 this.getValue() 
which will return the current column's binding value instead of
 dataSetRow["RUN"]

#1


2  

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.

我已经有一段时间没试过这么做了。突然想到的答案是,您需要将第三个数据集放到一个表中(可以将可见性设置为false),并且您需要将表值填充到一个GlobalValue中。然后您可以通过脚本从数据控件获取全局值。

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.

我知道它不漂亮。我将在周末查看一下,看看2.3是否添加了任何使这一过程更容易的功能。

#2


1  

Use the

使用

 this.getValue() 
which will return the current column's binding value instead of
 dataSetRow["RUN"]