Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

Anchor
columnwidth
columnwidth

The RowRenderer allows the user to change column widths by dragging the side of the column to another position. DomUI uses a mostly rewritten version of the jQuery extension colResizable (version 1.6) for this.

Column resizing is controlled by the resizeMode property on the data table which can have the following values:

ModeDescription
NONEColumn resizing is disabled
FIXEDThe total width of the table never changes; resizing column X will work by changing the width of column X+1
OVERFLOW

Column resizing is totally "free": resizing column X by dx pixels means that the table's width changes with dx pixels, possibly causing overflow of the table in its container.

This is the default mode.

FLEXTBD




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.