Re: How to dynamically resize the table width after adding/removing columns?

311 views
Skip to first unread message

James

unread,
Sep 20, 2012, 9:29:10 AM9/20/12
to google-we...@googlegroups.com
I have the same request. Can somebody answer this question?


James

On Wednesday, June 27, 2012 5:32:08 PM UTC-4, javadev79 wrote:
How do I ensure the datagrid expands to the total columns width or shrinks to the minimum table width on adding/removing columns?

Using refreshColumnWidths() after add/remove columns has no effect.

Andrei

unread,
Sep 20, 2012, 10:55:43 AM9/20/12
to google-we...@googlegroups.com
If you want the width of the DataGrid to change, set width of all columns in pixels, and use setWidth() on your DataGrid after each change.

If you want the width to be constant (a better option from the UI perspective, in my opinion), set the width of your DataGrid once and set width of at least one column in percentages. After you add or remove columns DataGrid will automatically resize columns to fit its width.

Minimum width setting is useful when you set width of your DataGrid as a percentage of its parent widget or add it to a layer of a resizable panel. When a browser window (or other content) forces DataGrid to change its size, it will automatically resize its columns until it hits the minimum width, at which point a horizontal scrollbar will appear and columns will not be resized anymore.

Reply all
Reply to author
Forward
0 new messages