Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » How to merge tow cells of the Grid row?
How to merge tow cells of the Grid row? [message #245853] Mon, 02 July 2007 10:09 Go to next message
Eclipse UserFriend
Originally posted by: HJiang.StateStreet.com

Hi, Now I have a 2*2 grid. I want to merge the second row into one cell
at runtime. Does anyone know how to do that? Please give me a sample.
Thanks a lot!
Re: How to merge tow cells of the Grid row? [message #245936 is a reply to message #245853] Mon, 02 July 2007 14:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

Alan,

Select the first cell in the second row of the grid, then hold the shift
key and select the second cell. After both are selected right click and
select merge cells.

Jason

Alan JIANG wrote:
> Hi, Now I have a 2*2 grid. I want to merge the second row into one cell
> at runtime. Does anyone know how to do that? Please give me a sample.
> Thanks a lot!
>
Re: How to merge tow cells of the Grid row? [message #246015 is a reply to message #245936] Tue, 03 July 2007 01:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: HJiang.StateStreet.com

Hi, Jason

I know how to do that in the design. I'm sorry that I didn't express this
in a clear way. Actually I want to merge two cells using the Report Design
Java API during the runtime. Then I can manipulate that cell. Please
advise. Thanks a lot.
Re: How to merge tow cells of the Grid row? [message #246056 is a reply to message #246015] Tue, 03 July 2007 05:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

Alan,

Try

RowHandle row1 = (RowHandle) gridHandle.getRows( ).get( 1 );
CellHandle cell1 = (CellHandle) row1.getCells( ).get( 1 );
CellHandle cell2 = (CellHandle) row1.getCells( ).get( 2 );
cell2.drop( );
cell1.setColumnSpan( 2 );


Jason

Alan JIANG wrote:
> Hi, Jason
>
> I know how to do that in the design. I'm sorry that I didn't express
> this in a clear way. Actually I want to merge two cells using the Report
> Design Java API during the runtime. Then I can manipulate that cell.
> Please advise. Thanks a lot.
>
icon5.gif  Re: How to merge tow cells of the Grid row? [message #759692 is a reply to message #245853] Tue, 29 November 2011 16:26 Go to previous messageGo to next message
Henning von Bargen is currently offline Henning von BargenFriend
Messages: 22
Registered: May 2011
Junior Member
Does anyone know if and how this is also possible to do this from *within* the report (with JS)?
Re: How to merge tow cells of the Grid row? [message #759710 is a reply to message #759692] Tue, 29 November 2011 17:11 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Yes this can be done in the beforefactory script. Have a look at the
attached example that does this with a table header ( note that the
table is named):

importPackage( Packages.org.eclipse.birt.report.model.api );
elementFactory = reportContext.getDesignHandle().getElementFactory()
var mytable = reportContext.getDesignHandle().findElement("mytable");

//get header and add label
var myheader = mytable.getHeader( ).get( 0 );
tcell = myheader.getCells( ).get( 1 ).drop();
tcell = myheader.getCells( ).get( 0 );

tcell.setColumnSpan(2);
tcell.setRowSpan(1);

Jason

On 11/29/2011 11:26 AM, h.vonbargen wrote:
> Does anyone know if and how this is also possible to do this from
> *within* the report (with JS)?
Re: How to merge tow cells of the Grid row? [message #759841 is a reply to message #759710] Wed, 30 November 2011 09:35 Go to previous messageGo to next message
Henning von Bargen is currently offline Henning von BargenFriend
Messages: 22
Registered: May 2011
Junior Member
Can this be done for a single instance, too?

The scenario is as follows:
I have a complex report showing analysis results and want to create PDF output.

Ihe results are shown grouped by the type of the result and (inside the groups) different layouts are used depending on the type.
For example, descriptive results are shown in a simple 2-column table name: value,
most of the results are shown in a 4-column table |parameter|method|result|unit,
and for special cases I need a predefined matrix layout of the results inside the group.
(e.g. the first result goes to cell B3, the second one to cell C3, the third to cell A4).
For other special cases I need a differend matrix layout (e.g. different cells merged, different column widths, different dimension).
What I was able to do is create a grid with a maximum dimension (say, 8x8), fill the cells with the results accordingly and hide the superfluous rows and columns.

But I cannot format the grid, e.g. merge cells and set column widths.

The same report may contain two ore more of these special cases.

I think that using the beforeFactory event is not an option, then?

BTW I also tried a different way and generate a complete HTML table dynamically, then show it using a DynamicText item.
Though officially not supported, BIRT (3.7.1) interpretes the HTML table, tr, td tags and renders the table nicely in the PDF output. Even colspan is working more or less.
However, BIRT ignores all width attributes (be it as HTML attributes or as inline style).
So I came up with the idea to use a 100-column table and then add colspan='20' for a column with 20% width.
This works basically.
The only problem is: If the cell has set a border, the PDF renderer generates a short line where a column with colspan='1' would end.

You can see what I mean with a simple example.
Create a report which displays a dynamic text item. Then use the following code for its value:
"<table width='150mm'>" +
"<tr><td align='center' colspan='30' style='border:1pt; width:30%;'>Name</td><td colspan='70' style='border:1pt; width:70%;'>was?</td></tr>" +
"<tr><td colspan='30' style='border:1pt;'>Flecki</td><td colspan='70' style='border:1pt;'>Katze</td></tr>" +
"<tr><td colspan='30' style='border:1pt; background-color:yellow; font-weight:bold'>Charlie</td><td colspan='70' style='border:1pt'>Kater</td></tr>" +
"<tr><td colspan='100' align='center' style='border:1pt; background-color:white;'><div style='background-color:pink'>Hier ist die Summenzeile. Sie besteht aus einem deutlich längeren Text</div></td></tr>" +
"</table>"


Note the short lines near the top left corners of the cells.
Re: How to merge tow cells of the Grid row? [message #759974 is a reply to message #759841] Wed, 30 November 2011 18:55 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You can set the row and column span dynamically per instance but you can
not drop a column or row. You could hide a cell dynamically. Look a
the second grid in the modified example and and look at the oncreate
script for cell1 and 2. One other option is to insert two detail rows
and then put in both grid types (one in each row) and hide the one you
do not want.

Jason

On 11/30/2011 4:35 AM, h.vonbargen wrote:
> Can this be done for a single instance, too?
>
> The scenario is as follows:
> I have a complex report showing analysis results and want to create PDF
> output.
>
> Ihe results are shown grouped by the type of the result and (inside the
> groups) different layouts are used depending on the type.
> For example, descriptive results are shown in a simple 2-column table
> name: value,
> most of the results are shown in a 4-column table
> |parameter|method|result|unit,
> and for special cases I need a predefined matrix layout of the results
> inside the group.
> (e.g. the first result goes to cell B3, the second one to cell C3, the
> third to cell A4).
> For other special cases I need a differend matrix layout (e.g. different
> cells merged, different column widths, different dimension).
> What I was able to do is create a grid with a maximum dimension (say,
> 8x8), fill the cells with the results accordingly and hide the
> superfluous rows and columns.
>
> But I cannot format the grid, e.g. merge cells and set column widths.
>
> The same report may contain two ore more of these special cases.
>
> I think that using the beforeFactory event is not an option, then?
>
> BTW I also tried a different way and generate a complete HTML table
> dynamically, then show it using a DynamicText item.
> Though officially not supported, BIRT (3.7.1) interpretes the HTML
> table, tr, td tags and renders the table nicely in the PDF output. Even
> colspan is working more or less.
> However, BIRT ignores all width attributes (be it as HTML attributes or
> as inline style).
> So I came up with the idea to use a 100-column table and then add
> colspan='20' for a column with 20% width.
> This works basically.
> The only problem is: If the cell has set a border, the PDF renderer
> generates a short line where a column with colspan='1' would end.
>
> You can see what I mean with a simple example.
> Create a report which displays a dynamic text item. Then use the
> following code for its value:
>
> "<table width='150mm'>" +
> "<tr><td align='center' colspan='30' style='border:1pt;
> width:30%;'>Name</td><td colspan='70' style='border:1pt;
> width:70%;'>was?</td></tr>" +
> "<tr><td colspan='30' style='border:1pt;'>Flecki</td><td colspan='70'
> style='border:1pt;'>Katze</td></tr>" +
> "<tr><td colspan='30' style='border:1pt; background-color:yellow;
> font-weight:bold'>Charlie</td><td colspan='70'
> style='border:1pt'>Kater</td></tr>" +
> "<tr><td colspan='100' align='center' style='border:1pt;
> background-color:white;'><div style='background-color:pink'>Hier ist die
> Summenzeile. Sie besteht aus einem deutlich längeren
> Text</div></td></tr>" +
> "</table>"
>
>
> Note the short lines near the top left corners of the cells.
Re: How to merge tow cells of the Grid row? [message #778490 is a reply to message #759841] Thu, 12 January 2012 20:51 Go to previous message
Muhammad Shahbaz is currently offline Muhammad ShahbazFriend
Messages: 1
Registered: January 2012
Junior Member
Hi h.vonbargen !

Iam facing the same issue while rendring report in pdf, colspan create a small line. Have u find any solution ?
Previous Topic:genReport.bat usage
Next Topic:How to Hide drill-through hyperlink information?
Goto Forum:
  


Current Time: Fri Nov 28 18:29:20 GMT 2014

Powered by FUDForum. Page generated in 0.09280 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software