How to adjust Grid-Columns width automatically? And stretch last?

Hello,

I would like to have a “lite view” and a “detailed view” of a grid.
Currently I do that with

[code]
checkbox_lite_view.addValueChangeListener(event → {
checkbox_lite_view.setValue(checkbox_lite_view.getValue());
if (checkbox_lite_view.getValue()){
table1.getColumn(“id”).setHidden(false);
table1.getColumn(“name”).setHidden(false);
table1.getColumn(“fullname”).setHidden(false);
table1.getColumn(“password”).setHidden(true);
table1.getColumn(“lastlogin”).setHidden(false);
table1.getColumn(“canlogin”).setHidden(true);
table1.getColumn(“admin”).setHidden(true);
table1.getColumn(“permissions”).setHidden(true);
table1.getColumn(“ip”).setHidden(true);
table1.getColumn(“lastcontent”).setHidden(true);
table1.getColumn(“ad”).setHidden(true);
table1.getColumn(“language”).setHidden(true);
table1.getColumn(“liteuser”).setHidden(true);
table1.setSizeFull();

} else {

table1.getColumn(“id”).setHidden(false);
table1.getColumn(“name”).setHidden(false);
table1.getColumn(“fullname”).setHidden(false);
table1.getColumn(“password”).setHidden(false);
table1.getColumn(“lastlogin”).setHidden(false);
table1.getColumn(“canlogin”).setHidden(false);
table1.getColumn(“admin”).setHidden(false);
table1.getColumn(“permissions”).setHidden(false);
table1.getColumn(“ip”).setHidden(false);
table1.getColumn(“lastcontent”).setHidden(false);
table1.getColumn(“ad”).setHidden(false);
table1.getColumn(“language”).setHidden(false);
table1.getColumn(“liteuser”).setHidden(false);
table1.setSizeFull();
}});
[/code]The problem is when ticking the Checkbox true and false, it changes the columns BUT it malforms the grid badly…
So my questions are:

  1. How do I set column width to fit items automatically?
  2. How do I stretch last column to fill the whole table?
  3. Is there a way to make the Grid smaller? So text and grid in general is smaller so more columns fit on a site?

Thank you for your help!

You should use column expandRatio property; this one sets the importance of a column when system computes its width.