Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Set table header from a different data set
paqman
Hello Birt Exchange,<br />
<br />
I'm trying to set the column headers in a table using a different data set than the one the table data comes from, but am having problems. The XML Data Source is in the following format:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<ReportData>
<GroupDetail>
<GroupNo>1</GroupNo>
<GroupName>Name of the first group</GroupName>
</GroupDetail>
<GroupDetail>
<GroupNo>2</GroupNo>
<GroupName>Name of second group</GroupName>
</GroupDetail>
<Row>
<Time>00:00:00</Time>
<Data1>15.5</Data1>
<Data2>20</Data2>
</Row>
<Row>
<Time>00:15:00</Time>
<Data1>28.9</Data1>
<Data2>50.5</Data2>
</Row>
</ReportData></pre>
<br />
The current table (without column headers) uses a Data Set mapped to //Row. It has 9 columns, one for Time and one for each possible Datax entry (we support up to 8 in the report). Missing data columns are then hidden. This probably isn't the best way of doing it, but it works.<br />
<br />
I've just created another Data Set mapped to //GroupDetail. It is picking up the GroupName parameter properly. So... what is a good way of getting those GroupNames into the header row? I have tried using global variables (populating them onFetch of the Data Set) but they never seem to be given a value (always NULL in the table).<br />
<br />
One thing I have considered is moving GroupName to be within each <Row> node, but then I am wasting a whole bunch of data (since I only really need to give that information once). <br />
<br />
Thanks in advance!
Find more posts tagged with
Comments
mwilliams
The persistent global variable way would be a good way to do it. Most likely, you're getting null values because you need to have an element that is tied to the column titles dataSet before the table tied to the other dataSet. You can use a simple text element at the top of your report and hide it. This will cause the titles dataSet to be ran first so the PGVs are set.
paqman
OK that makes sense. Is there another topic with an example of how to properly set up that kind of script in a table (to get a field value)? In other reports, other elements like the Cross Tab have listed event functions in the script window (like onCreate has onCreateCell and onCreateCrosstab for the cross tab) which include reportContext as a parameter, allowing me to set the global variable. When I look at the script window for a table, there are no event functions (and I cannot get access to reportContext to set the variable).
mwilliams
What's your BIRT version? I'll create a quick sample.
paqman
We are running 2.6.2
Thanks!
mwilliams
The attached report shows how to bring titles from a titles dataset and apply them to the tables in the report.