How to detect dynamic text overflow in Birt - birt

In Birt I have som dynamic text elements with fixed widths. I want to compare the text that will populate the element with the width of the element to populate the element with some other value when the text is too long. Is this possible?

No.
But AFAIK if you use the PDF emitter, you could determine the needed width of a given text in a given font/size with some iText API. But you have to take into account padding, margin etc. yourself.

Related

Can NSCollectionViewCompositionalLayout support "growing cells"

I have a collection view showing a simple one-column list with a NSCollectionViewCompositionalLayout. The cells take the full width and have a fixed height.
I would like that, upon an external event, one of the cell grows in height (animated).
That could be for example :
when the cell is selected
when an image shown in the cell is downloaded
I found no way to do this in Apple's doc, when I think this is a fairly common use case. It seems that NSCollectionViewCompositionalLayout is very flexible in positioning cells, but very static. All cell sizes are computed once and for all.
Is there any API for this ? What's the way ?

Stacked table column widths

You can use a GeneXus HTML table to layout text blocks and attributes. If I add a second table to contain some other information that I want to conditionally display, quite often, the first cell is a different width to the first cells of the table stacked above it.
How do you make all the columns/cells the same width so that stacked tables display with their contents correctly aligned?
This is for GeneXus Web in Evo 2 & 3.
Thanks
Put a value in the width property of the client table first cell.
So, put the same value in the width property of the password table first cell.
Remember that the width value must be enough for both tables. In your case, the biggest textblock is the "Client Name". So, choose a width enough for that.
Best regards.
If you don't set a width, HTML will assume the minimum width required to accommodate the content. If you don't want it to be set automatically when when the page is displayed, you have to decide on a width.
In your case, you have to put the same width value for a cell (any cell) in the first column of both tables.

How to center the report title in RDLC file

I am trying to center the report title placed within report header on RDLC matrix report - this should have been quite straight-forward but I am struggling to achieve it.
I am using VS 2010 (SP1) report designer to edit the RDLC. The report is quite simple - it contains report header with two text-boxes and body containing matrix (cross-tab) report. Out of two Report Header text-boxes, one is used for display static report title while other is used to display the single report parameter.
The report content is as I want except I am unable to center the report title. The title get centered within the text-box width but I could not find a way to say that text-box should spawn entire page width. I cannot set text-box width to the page width because
if text-box width is set more than matrix width by say x inches then when report is rendered, content width gets enlarged by x inches from a rendered matrix resulting in page-width overlap.
it will need re-setting the text-box width if margins or page-size is changed
And a year and a half later... I used your solution but then found another one:
Clicking on the empty area of the report there is a property called ConsumeContainerWhitespace. It indicates wether white space to the right and below a matrix (or any content that can be resized) should be preserved. Might have other side effects though.
When the report gets wider than the page it looks like this in the viewer:
This will be printed on two pages and on each one the title will be centered.
Alas! got some time to play with RDLC - here's the work-around. Although, its not exactly what I want (a centered report title), its close enough!
Basic idea here is that matrix (cross-tab) report grows its width so you need to associate the report title with the matrix. So remove report header or page header and instead add one or more static row above the row-group in the matrix. Use these rows for Report tile and report parameters. By centering the report title text-box, you get some-what centered report title.

How do I autosize the column in SlickGrid?

I want slickgrid to autosize the columns based on the widest content or header text - whichever is wider. In simpler terms, I want it to simulate the default behavior of regular HTML tables when it comes to column sizing. How can I do it in slickgrid?
When constructing your options, you can use forceFitColumns: true
var options = {
enableCellNavigation: true,
forceFitColumns: true
};
This will make the columns fill the entire width of your grid div.
The OP is looking for columns to grow to match their content. grid.autosizeColumns() grows the cells to fit the parent container, which is not the same thing.
I have added this feature, and it is about as manual as you might imagine. You loop through the displayed cells and measure each one, saving the widest cell and using that width to set the width of your column. SlickGrid gives you good access to the cells in the viewport, so that works nicely.
The measurement algorithm is your big decision. You may put the content off screen and measure it, as #jay suggests. This works, but it is the slowest method, as it requires a repaint to insert, and a repaint when you remove. There may be ways to optimize. The solution I went with is to measure the width of every letter in the alphabet, as well as other typographic characters we come across, and sum them to generate a width. Yes, this sounds absurd. It has many constraints: The font size must be the same, it doesn't support images, there can't be any line returns, and more. If you can live with the constraints though, you can calculate sizes for a huge grid viewport in <5ms, because the character widths are only measured once.
After you get the sizes of the columns, you assign them to your columns using grid.setColumns().
Slickgrid will not support column auto size based on data.You need to write a plugin or fork the slickgrid core to modify.
Here is the link I have created a plugin to handle slickgrid auto size
https://github.com/naresh-n/slickgrid-column-data-autosize
I added this after the grid is drawn and it works fine.
$(window).resize(function() {
var cols = grid.getColumns();
grid.setColumns(cols);
})
You should be able to call the autosizeColumns() method of the grid object.
grid.autosizeColumns();
Make this simple adjustment to Naresh's https://github.com/naresh-n/slickgrid-column-data-autosize, on the init function:
Add $container.ready(resizeAllColumns); to the init function.
This ensures the columns autoresize on initial load
Insert the text into an off-screen element and retrieve the width of the element. This is what excanvas does to measure text. Use this to set the width of the column since it's expecting a pixel value.

BIRT -line spacing in report design

I wonder how to define the line spacing in a multi-line lable or text item for pdf output. While increasing the line height within a style works fine, decreasing the height to reduce line spacing doesn't seem to work.
Any suggestions on how to reduce the line pitch?
Thanks
Try removing top and bottom padding. I don't know about labels and text items, and maybe it's not the same, but I had a similar problem in a table with 8pt font in the details. It would look fine in HTML, but in PDF the space between the lines would be huge.
A good trick is to set background colors on the item and the surrounding cell and whatever other elements you have and you'll be able to see which element steals the space.
Then tweak the paddings, line height and font size to reduce the extra space as much as possible. Use the 'Advanced' properties panel (or preferably stylesheets), as line height is not available in 'General' for some elements.
I managed to get my table looking great doing this if I removed ALL top and bottom padding (from row, cell and data element), used a row line height of 10pt and a font size of 8pt.
There seems to be a bug that causes the actual text inside the data element to be somehow padded at the top no matter what in PDF. If you color the data element background and then select the text in the report, you'll see that the text is set too low on the element, overflowing a little at the bottom. Thats the reason 8pt font and 8pt line height wouldn't work for me, it would cut off the bottom of the text.

Resources