Dynamically determining a tables height.

Dynamically determining a tables height.

Forum member · Aug 9, 2006
I need to dynamically change the height of a table depending on the amount of text that is to be added to it. Is there a way to determine how high a table, of fixed width, most be to contain a text string that is of X font size? Thanks, Robi

Re: Dynamically determining a tables height.

Support · Aug 9, 2006
Yes, Robi. The table has a GetRequiredHeight method that will return the exact value that you need. IT will return to you the required height that it will take to fit all the elements that have been added to the table. So by resetting the Height of the Table to the GetRequiredHeight you will see the entire table (as long as there is sufficient room on the page). Thanks, ceTe Software Support Team

Re: Dynamically determining a tables height.

Forum member · Aug 9, 2006
Great. BTW.. your company's responsiveness is fantastic.

Re: Dynamically determining a tables height.

Forum member · Aug 10, 2006
Do i have to use TextArea to use getRequiredHeight()? TextArea seems to require X,Y coordinates and I want to dump my text into a table, then figure out how big the Table needs to be so I can then draw another table in relationship to the first. Using TextArea requires me to add the X,Y, and width and height which in my case I wont know.

Re: Dynamically determining a tables height.

Support · Aug 10, 2006
Hello, You can use the getRequiredHeight() method on the Table page element without having to use TextArea. If you plan on using TextArea, the co-ordinates of the TextArea will be relative to the cell and you can set them to zero and you can specify any height and then reset the height equal to getRequiredHeight. Also the width can be set equal to the width of the column or cell. Thanks, ceTe Software Support Team

Re: Dynamically determining a tables height.

Forum member · Aug 10, 2006
Can you point to an example? I still can not understand how to get the required height. For example I have a table created like this : Table table1 = new Table(-2, -2, 190, 80, Font.getHelvetica(), 12); leftTable(table1); row.getCellList().add(table1); This table is added to a row that’s inside a table. The method leftTable() adds the content to table1. The content in leftTable is coming from the Database and I don’t know its height. What I need to know is how to make table1 the correct height to match the content coming out as well as for positioning of other items. I tried using getRequiredHeight and looking at the examples but they all require the object to already be made. So I can do table1.getRequiredHeight() but I don’t understand how I can get the required height to my table before its created.

Re: Dynamically determining a tables height.

Support · Aug 10, 2006
Hello, In the example you gave, in order to reset the height of the inner table to the getRequiredHeight please refer to the modified code below: Table table1 = new Table(-2, -2, 190, 80, Font.getHelvetica(), 12); leftTable(table1); table1.setHeight(table1.getRequiredHeight()); row.getCellList().add(table1); This will reset the height of the inner table. You can declare the table to be of any height and later reset the height to the required height without any problem. Thanks, ceTe Software Support Team

Re: Dynamically determining a tables height.

Forum member · Aug 10, 2006
ahh ok that makes sense. thanks again, robi