...
Warning |
---|
It is important to specify some realistic width because otherwise the column sizes will change with every render of the table. This is very ugly especially when paging the table: every time the user presses 'next page' the sizes of the columns change. This is especially so when you use odd widths, like all columns with "1%" except the last one at '90%'. Do not do that. |
Column width changes by the user
The RowRenderer allows the user to change column widths by dragging the side of the column to another position. DomUI uses the jQuery extension colResizable for this. When the user changes a column width DomUI calls a server callback so that the column size change can be saved if that is wanted. Column width change events can be received by adding a listener to the row renderer as follows:
Code Block |
---|
renderer.setColumnListener(new IColumnListener<Object>() {
@Override public void columnsChanged(TableModelTableBase<Object> tbl, List<ColumnWidth<Object, ?>> newWidths) throws Exception {
saveColumnWidths(tbl, newWidths);
}); |
Since doing this for every row renderer is a lot of work you can also register a "global" listener inside DomApplication's initialize method, as follows:
Code Block |
---|
setAttribute(RowRenderer.COLUMN_LISTENER, new IColumnListener<Object>() {
@Override public void columnsChanged(TableModelTableBase<Object> tbl, List<ColumnWidth<Object, ?>> newWidths) throws Exception {
saveColumnWidths(tbl, newWidths);
}
}); |
This listener gets called for every data table / RowRenderer when a column width changes, and can be used to implement some global mechanism to handle the storing of column sizes.