Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Report Headings
briann
I have a report that will have 4 columns. Each column will need to use the same field from the dataset. Each record will have a different value in the field, for example. 1st record has Operator Id, 2nd record has Transaction Date, etc. I tried creating computed columns, but when the table loads, it only reads the 1st record, therefore, I get Operator Id in every column heading. Basically what I need is to load 4 different fields, and then use them as my column headings. Or any other method that would work. Any suggestions?
Find more posts tagged with
Comments
mwilliams
In the onFetch of your dataSet, you could store the values into an array or into persistent global variables, then recall them in a dynamic textbox as the column header. Let me know if I'm misunderstanding something or if you need more information.
briann
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="96013" data-time="1329160589" data-date="13 February 2012 - 12:16 PM"><p>
In the onFetch of your dataSet, you could store the values into an array or into persistent global variables, then recall them in a dynamic textbox as the column header. Let me know if I'm misunderstanding something or if you need more information.<br /></p></blockquote>
That's exactly what I'm looking to do. Can you provide an example, or point me to an example?
mwilliams
Sure, what's your BIRT version?
briann
Eclipse BIRT Designer Version 3.7.1.v20110905
Basically I have a dataset that is used as a translation table. I have field1 which is the english text, and field2 which is the spanish text. I have 4 total records.
1st record field1 = Date, field2 = Fecha.
2nd record field1 = Time, field2 = Hora.
These values are going to be used as my column headings. Based on a parameter the user chooses, I will need to load hold fields that will contain either the english text or the spanish text. I need these hold fields loaded before the report runs. I will then use the newly loaded hold fields as my column headings.
mwilliams
Take a look at this design. It shows the persistent global variable way. The first header text box is bound to the headers data set to force it to run and set the pgv's. The parameter value is checked in the onFetch of the data set and the pgv's are filled. Then, they are recalled in the text boxes in the table header. Hope this helps.
briann
I see you have an array setup in the OPEN. I do NOT have open. I have onfetch and that's it. Is there a way to add OPEN?
mwilliams
The OPEN and FETCH scripts are only there because I used a scripted dataSet to create the headings dataSet. These script areas are not important to the concept of using your dataSet data for the headers. The onFetch is the only one that matters, as stated in my explanation above. Let me know if you're still confused on the reason for this script.
briann
Thank you for the example, I would have never been able to figure that out. I can't get this to work though. Here is the exact information I'm trying to retrieve.
DataSet Field Field Field
Abslabel Tlabel Tvalue Tlang
Record1 Date Fecha ESP
Record2 Time Hora ESP
Record3 Transaction Accion ESP
User selected English Report - Column1 = Date, Column2 = Time, Column3 = Transaction
User selected Spanish Report - Column1 = Fecha, Column2 = Hora, Column3 = Accion
How would I modify your example below to achieve the above?
if (params["Language"].value == "English"){reportContext.setPersistentGlobalVariable("column" + headerDSRow.toString(),row["English Heading"]);}else{reportContext.setPersistentGlobalVariable("column" + headerDSRow.toString(),row["Spanish Heading"]);}headerDSRow++;
mwilliams
That's the script within the dataSet. What that means is:
if (whatever tells you what report they chose == English){
set the PGVs with the english labels.
}
else{
set the PGVs with the spanish labels.
}
increment row/column differentiating variable that makes each value go to a different PGV
If "Tlang" is the chosen language, you'd just check this field. If it is spanish, you store the spanish field, if it's english, the english ones. Then, you increment the variable that's used in the PGV names to make the names different. This variable is initialized in the report's initialize method. Let me know if you have questions.
briann
I must be missing something. I cannot get this to work. I added a text box to my header, and the PGV will NOT display. I set this up exactly how you have it, and am having no luck. You have your text box setup as HTML, as do I. Do I need to do anything else? Am I missing a step? Sorry to keep bothering you, but this is the last piece of the report I need to get done...
This is my script...
if (params["Language"].value == "English")
{reportContext.setPersistentGlobalVariable("column" + headerDSRow.toString(),row["TLABEL"]);}
else
{reportContext.setPersistentGlobalVariable("column" + headerDSRow.toString(),row["TVALUE"]);}
headerDSRow++;
I also tried...
if (row["TLABEL"].value == "DATE")
{reportContext.setPersistentGlobalVariable("column" + headerDSRow.toString(),row["TLABEL"]);}
else
{reportContext.setPersistentGlobalVariable("column" + headerDSRow.toString(),row["TVALUE"]);}
headerDSRow++;
mwilliams
Did you initialize the headerDSRow variable somewhere? Can you just attach your design?
briann
I have attached my report. No I did NOT initialize my headerdsrow. I don't even know how to do that.
briann
From your example I figured out how to initialize the headerdsrow, however, it's still not working. I put the initialize in the Report Design Initialize Script.
mwilliams
In my explanation above, I said that you needed to select the first heading text box and bind it to the headers dataset. Did you do that?
Also, I don't see the attached design. Can you please try again? Thanks!
briann
That's exactly what I was missing. I didn't bind the text box to a dataset. It's working now. Thank you very much for your patience, it is very much appreciated. Keep up the great work...
briann
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="96112" data-time="1329318481" data-date="15 February 2012 - 08:08 AM"><p>
In my explanation above, I said that you needed to select the first heading text box and bind it to the headers dataset. Did you do that?<br />
<br />
Also, I don't see the attached design. Can you please try again? Thanks!<br /></p></blockquote>
<br />
1 more question. See below. On my ELSE statement, how do I hard code the PGV to a specific value? I tried this below, but it doesn't work.<br />
<br />
<br />
if (row["TLABEL"].value != " "){<br />
reportContext.setPersistentGlobalVariable("column" + headerDSRow.toString(),row["TVALUE"]);<br />
}<br />
else<br />
reportContext.setPersistentGlobalVariable("column" + headerDSRow.toString(),"DATE");<br />
headerDSRow++;
mwilliams
The setPGV in the else condition looks good. You should get a value of "DATE" if the condition is not met. The issue is probably with your actual condition. It appears that you put "<space>". If so, the only time you'd get "DATE" would be if the field value was a space. You might try "" or null instead as the condition check. Let me know.