Jump to content

Column layout with a label on the left.


ejhellerattc

Recommended Posts

Theoretically simple. Generate a table that is oriented horizontally across the page as part of an overall report that is oriented portrait.

Report......

Day Number Day 1 Day 2 Day 3 Day 4
Plan Number 1 2 45 32
Action ID AJBGT KIUJ3 P98U LKIU7
Start Time 11:00 14:00 08:00 13:45
End Time 12:00 16:00 10:00 16:00
Supervisor ABC DEF GHI JKL

More Report...

In the example, there may be 1 plan or 50 plans. The data comes an SQL query and it makes more sense to send the across the page for up to 10 plans per row than down the page for 5 columns of data. In addition, this is the client requested layout.

The data part can be done by createing a sub report that uses the space to create multiple columns and placing the data elements vertically oriented in the detail column.

The tricky part is how to have labels for the rows displayed to the left of each row of data. Unlike the Horizontal demo report, I do not want to use real estate by duplicating the label in each cell.  I tried placing a set of labels to the left of the sub report reference in the main report, however when the data wrapped in the sub report to create a new row of data rows, the labels were not duplicated.

Suggestions are appreciaed.

Thanks.

Ed.

 

 

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

A part of the problem can be solved using prinWhenExpressions for row labels, something like:

<printWhenExpression><![CDATA[$V{REPORT_COUNT}%10 == 1]]></printWhenExpression>

Also, with printWhenExpressions you could reposition the textfields with data in the columns 2-10, in order to get a better layout in the absence of labels.

But another part of the problem is to resize columns that contain no labels, in order to reduce the unused space, like in your example. For the moment I don't see an easy way for this one. Maybe someone else could help.

Regards,

sanda
 

Link to comment
Share on other sites

Sanda,

Thanks for the response. I tried the PrintWhen. I set up the label to be PrintWhen based on the Report_Count  and not print the value when the label is printed. However, this effectively skips a data row. I also tried the PrintWhen to add a label in the left cell above the data, but it just does not look good.

I am unclear about your suggestion to resize the columns. Please note that the table shown is a best approximation using the table control in this forum editor tool, not what my report looks like.

Thanks,

Ed.

Link to comment
Share on other sites

Well, that's why JRXML samples are always welcomed, in order to make sure that we are talking about the same things. Please attach them (master & subreport) if possible, it could help a lot.

My current understanding is that in a master report with normal (vertical) flow you need to insert a subreport with horizontal flow, but with labels repeated only when a new row is started. Please correct me if I'm wrong.

If I'm not wrong, then in a report with horizontal filling this condition can be accomplished with a printWhen condition. Also this would generate some amount of unused space in columns where labels are no more printed.

But this is a general situation.

In our particular case it's important to see the report templates, in order to find the appropriate solution.

Thank you,

sanda

Link to comment
Share on other sites

Thank you for the samples, Ed. They completely clarified the situation.

I think there is a solution for this report layout, although a little bit tricky.

The basic idea is to force the subreport query to retrieve always only the next 5 records in the data source that match criteria (because there are only 5 columns in the subreport).

Of course, the subreport should be called several times with an incremental parameter, in order to retrieve all necessary data.
This means several records are needed in the master report's datasource, not a single one. You have to calculate this number of records at fill time and pass it as parameter in the master query.

For instance, if there are 28 meaningful records in the DB, they have to be represented on 28/5 + 1 = 5 + 1 = 6 rows. The master should have 6 records, in order to call the subreport 6 times.

The attached files contain the modified layout in order to illustrate the above approach. The rest of the report content vas moved from the <detail/> section in <title/> and <summary/>. I also used 25 data records from the Sample HSQLDB database that comes with iReport, in order to run the report with some consistent data. Please take a look at the report templates and see how these were modified. You can run them in iReport against the Sample HSQLDB. Use default values for parameters.

Hope this helps. Please let me know if you still have problems.

sanda
 

Link to comment
Share on other sites

  • 2 weeks later...

Thanks for the information. I have been trying out this and other processes (in addition to other tasks).

In my initial request, I may have misspoke. The data actually comes from a CSV file (sort like a SQL, but not exactly, thus the misspeak). Because it is CSV, it is not possible with JR to perform SQL queries.

Since I have control over the CSV format and generation, I suspect that I am going to have to drop back to a kludge. Every Nth record is the row lables. This, with some print whens to do formatting, allows the report to print the row lables. What is not nice about this approach is that the row lables cannot be a different width than the data.

Thanks,

Ed.

Link to comment
Share on other sites

  • 10 years later...

After 10 years, I had an epiphany.

The CSV data source was oriented like the table, just transposed:

Day1,1,AJBGT,11:00,12:00,ABCDay2,2,KIUJ3,14:00,16:00,DEFDay3,45,P98U,08:00,10:00,GHI

Etc.

Since I can control the CSV, if I have the data as three columns: Index, DataType and Value, then I can create a CrossTab that does what I need:

Day 1, Plan Number, 1Day 1, Action ID, AJBGTDay 1, Start Time, 11:00Day 1, End Time, 12:00Day 1, Supervisor, ABC

The CrossTab has COLUMN_0 as the header, COLUMN_1 as the row label and COLUMN_3 as the data (no computation). Modifying the CrossTab to not have Totals for the Groups prevents the Totals column and row from appearing.

Not pretty, but it works.

Posted for others who may have wondered.

Ed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...