0
votes

Hello all) The task looked pretty easy - to get FlexTable's width and set this width to ScrollPanel to get rid of horizontal scrollbar - until I figured out that any method like table.getElement().getClientWidth() returns only 0.

Maybe smth wrong with the way I do it - I create table, fill it with data then call int tableHeight = table.getElement().getClientWidth(); and this int is 0 despite the table itself looks normal in browser and its width 310 px.

Thanks a lot for any help.

1

1 Answers

0
votes

if you want to get what width a flextable has, you can use:

table.getElement().getStyle().getWidth();

But that will only return the width that is set to it. To set a width, you can use:

table.setWidth();

Note: the getWidth() method will return whatever CSS width your table has, whether or not it was set programmatically.

Also, getClientWidth() would only give you the width of the table after it was attached to the parent widget, which is probably why it why it is returning 0 for you.