How to set default presentation for table

Hello…
I have a table with many columns(20+)… But i want some 5 columns as defaulty shown in the table… I know we can save the presentation by unchecking the column in the presentation. But how do i make only those 5 columns are selected by default…?

In the xml of your table, add collapsed=“true” for columns that you want hidden initially.

-b

Thanks @b.tel for the information. But in my case… I’ve dynamic fields also, How do i set collapsed=true for dynamic fields?

Hi,

Could you clarify, what do you mean by dynamic fields? Are these columns generated columns or correspond to dynamic attributes?

Regards,
Gleb

Sorry… I actually meant Dynamic Attributes…

Only option I can think of is looping the table columns in code and set them to collapse except for the intended ones. Don’t know how that holds with presentations.

Alternatively you could loop the dynamic attributes instead of the table columns.

-b

Thanks for the reply @b.tel
Can anybody share some code samples. So, i can learn and use…
Thanks…

Here is a straightforward piece of code doing it (not tested):

@Override
public void init(Map<String, Object> params) {
     super.init(params);

     yourTable.getColumns().forEach(c -> c.setCollapsed(true));
     yourTable.getColumn("visibleColumn").setCollapsed(false);
     // Set columns visible as needed
}

Thank you @b.tel It works as expected…