cancel
Showing results for 
Search instead for 
Did you mean: 

Determine table width with code.

Former Member
0 Kudos

Hello,

I have a table that is linked to a datasource. The table's columns resize to fit the retrieved values.

I want to determine what the columns' sizes (getWidht) are after retrieval and use these values to change a second table's columns to be the same sizes (setWidth).

Can someone please show me the code how to do this?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I got this to work. The Table and Column Sizes do not display as it's empty unless you specify it.

IWDView view = (IWDView)wdControllerAPI;

IWDTable itemTable = (IWDTable)view.getElement("EmpTable");

IWDTableColumn column = (IWDTableColumn) itemTable.getView().getElement(itemTable.getGroupedColumn(1).getId());

String result = "Table Size: " + itemTable.getWidth();

result += " Grouped Cols: " + itemTable.numberOfGroupedColumns();

result += " Row Count: " + itemTable.getVisibleRowCount();

result += " Grouped Cols Length: " + itemTable.getGroupedColumns().length;

result += " Grouped Cols ID: " + itemTable.getGroupedColumn(1).getId();

result += "Column Size: " + column.getWidth();

//depreciated result += "Column Size: " + itemTable.getColumn(0).getWidth();

wdContext.currentContextElement().setTCellSize(result);

Former Member
0 Kudos

Hi,

Yes it is not possible to get the width of the table if we dont specify in that field.

Can you try by getting the length of the larger text in that column while populating data into second table.

Using the length of larger text then fix the width of second table.

Or

Specify the width to each and every column in both the table and change the textView wrap property of all the columns to true. So that the size of the columns will be fixed and user can read all the text.

Regards,

Charan

Former Member
0 Kudos

Hi,

Put your code in the wdDoModifyView method. This way, the width of the 2nd table will be changed when the width of the 1st table changes.

Regards,

Pierre