0

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 Answers1

0

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.

Churro
  • 4,166
  • 3
  • 25
  • 26
  • So, am I right - after attaching this table to scrollPanel its getClientWidth() should return the real width? I want to avoid hardcoding the width because my flextable is user-dependent so its size may vary for different users. The best would be populate it with data then get its size and put it in scrollpanel but I am not sure whether it is possible. – user2676881 Aug 13 '13 at 19:38