Set group by column without user action in table header

88 views Asked by At

Is there an option to automatically group table data by specific column without user action to group by column in table header.

When I click on column and set Group, table is grouped by that column and that looks awesome, now I need that option to set in code, without user interaction.

Thanks

2

There are 2 answers

2
Stephan Merkli On BEST ANSWER

Yes, you can return true in AbstractColumn.getConfiguredGrouped() of your column. You need to set getConfiguredSortIndex() too.

If you made manual changes in your table (e.g. changed column width, order, ..), you may need to reset your table to the defaults via the setting icon.

0
Andre On

When you want to change the sort columns programmatically at runtime you can use the column-set of the table. Something like this:

ITable table = getTable();
ColumnSet colSet = table.getColumnSet();
IColumn<?> sortCol = colSet.getColumnByClass(MyColumn.class);
colSet.addSortColumn(sortCol, true);