Home
Analytics
Question on layout and table cell word wrap
ssen
I have 2 tables laid out one below the other in a page.
The bottom table has 2 columns and column 2 can contain very long string, and column 1 has fixed size labels.
When a long string is displayed in col2 of the bottom table, I see the following:
The string in col2 is not wrapped. This creates a very wide page. col1 is shrunk to its minimum so that the labels are multi-line which I do not want.
Table 1 (the top table) is laid out such that the columns are now resized to fill the entire page - so the text that is right justified cannot be seen without scrolling right.
How do I solve this?
I was thinking of setting some style to the col2 of the bottom table so that the strings are wrapped, but I am not clear on how to do it.
Also, is there any way to restrict the the layout of the top table so that the columns are not resized?
Thanks for any help.
Shantanu Sen
Find more posts tagged with
Comments
mwilliams
Hi Shantanu Sen,
What version of BIRT are you using? What output are you using? HTML? Have you tried setting widths for all of your columns in both tables?
ssen
Hi Michael,
I am using version 2.2 with HTML output. I have tried specifying fixed size to the columns of the bottom table and the absolute value of the table width of the bottom table is smaller than the one for the top table.
The issue is when the text in the col2 of the bottom table is arbitrarily long AND without any space i.e. it has no delimiter. In this case the column width becomes equal to the length of the text.
Is there any way to specify a style to the col2 of the bottom table so that it breaks/wraps the text after reaching a certain length even if there is no standard delimiter such as space?
Thanks,
Shantanu
mwilliams
Shantanu,
If I remember correctly, I tested this in 2.3.0 not too long ago and the unbroken string (URL) did wrap to the next row. I could be mistaken, but I'm pretty sure this changed between 2.2 and 2.3. Without upgrading, the only solution I could think of would be to use the substr() function to break up the long string.
ssen
Michael,
We cannot move to 2.3 at this time. Can you point me to a sample that shows how to use the substr() function for breaking the string?
Thanks,
Shantanu
mwilliams
Shantanu,
What release of 2.2 are you using? I just did a table in version 2.2.2 with a computed column that had an unbroken string as the value. It wrapped with the size of the window. Did not require me to scroll. Attached are screenshots of smaller window and larger window from 2.2.2.
mwilliams
Can you give me an example of a long, unbroken string that you would use so I can test on it?
ssen
Michael,
Attached is a sample of what I am seeing in the preview pane. See how the col1 of the top table is stretched and the col2 of the bottom table stretches out.
I must be missing something in terms of wrapping the text.
The version that I am working off is 2.2.2.r222_v20071023
Here is the example string - there is no line break:
Attribute11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111Test or cancel;
Thanks for your help.
Shantanu
mwilliams
Shantanu,
That doesn't wrap for me either. BIRT must recognize the '-' in the URL I was using as a place it could break. I'll have to test this type of continuous test string in 2.3 as well to see if it's different there.
mwilliams
Shantanu,<br />
<br />
Here's how you can go about breaking it up with the substr() function. I did this in a computed column in the dataSet. You could also just do this in a data binding on your table. I'm breaking the string up into lengths of 25.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
len = row["UnbrokenString"].length; //gets length of unbroken string
lines = Math.ceil(len/25); //counts the amount of times you'll have to use the substr() function
i=1; //initialize line counter
marker = 0; //initialize placeholder
display = ""; //initialize output
//step through the string breaking it up with 25 character segments and adding a space between segments
while (i<lines){
display = display + " " + row["UnbrokenString"].substr(marker, 25);
marker = marker + 25;
i++;
}
//use the len variable and marker variable to determine how much is left and add it to the output variable
display = display + " " + row["UnbrokenString"].substr(marker, len-marker);
//output the broken string
display;
</pre>
<br />
Hope this helps.