Enhancement
Analogous to Excel, it should be possible to display a line in tables (including grids) that represents one calculated value per column.
- The evaluation row is optional.
- The evaluation row can be displayed configuratively either directly below the header or above the footer.
- The evaluation row behaves analogously to the header or footer row (i.e. it only scrolls horizontally with the columns, but not vertically with the rows, so it is always visible).
- For each column, an algorithm can be configured that calculates the value to be displayed in the evaluation row for that column. If no algorithm is configured, no value will be displayed in the evaluation row.
- The algorithm for calculating the value for the evaluation row gets access to the TableViewModel to make the calculation.
Conversion
Table columns have got the additional property additionalHeaders. This is a list of HTMLFragmentProviders, each of which writes an additional header line. Examples can be found in section [#Test|Test]. The following was done additionally:
- HTMLFragmentProvider was introduced as a generalization of ControlProvider.
- As an adapter for "old" APIs, which still declare ControlProvider, there is the FragmentControlProvider. This is a ControlProvider and has a property for an HTMLFragmentProvider.
- TL 6: The following TL script functions have been implemented:
- max, min, average, sum.
- These are documented like all other TL-Script functions in the folder com.top_logic.model.search/webapp/doc. This documentation is shown in the demo for example in the model based search in the second tab if you enter "sum" and press CTRL SPACE.
- AdditionalHeaderControl and SimpleAdditionalHeaderControl were introduced as base classes for new additional columns.
- By means of the shorthand <min/> the following predefined ControlProviders can be used: min, max, average, median, sum, nullCount, nullPercentage.
- There are no additional lines in the footer. This is too complex and will only be implemented after a complete redesign of the Frozen Table technology. Such a redesign is not foreseeable at the moment.
- The controls are called as soon as a row in the table is added, changed, removed and as soon as the table is rewritten (more precisely: TableModelEvent.INVALIDATE).
- The controls get an AdditionalHeaderControlModel as model. Over it they get the list of the column values by means of getValues().
- Exactly the displayed rows:
- Filtered rows are NOT included.
- In trees subelements of collapsed nodes are NOT included.
- Rows outside the ViewPort ARE included.
- Rows on other pages of the table ARE included.
- Rows are sorted as they are currently displayed.
- In addition, the control have access to via above class:
- getColumnIndex
- getColumnName
- getDisplayedRows
- getTableViewModel
- getRenderState
Code Migration
If a TableRenderer overwrites the method writeColumnHeader: At the beginning of the method it must be additionally checked whether it is an additional header column. In this case super must be called. See for example the DemoTableRenderer:
#!patch Index: branches/CWS/CWS_23681/com.top_logic.demo/src/com/top_logic/demo/table/DemoTableRenderer.java =================================================================== --- branches/CWS/CWS_23681/com.top_logic.demo/src/com/top_logic/demo/table/DemoTableRenderer.java (revision 281102) +++ branches/CWS/CWS_23681/com.top_logic.demo/src/com/top_logic/demo/table/DemoTableRenderer.java (revision 281391) @@ -19,19 +19,19 @@ */ public class DemoTableRenderer extends DefaultTableRenderer { public DemoTableRenderer(InstantiationContext context, Config config) throws ConfigurationException { super(context, config); } @Override public void writeColumnHeader(DisplayContext context, TagWriter out, RenderState state, int rowNumber, int column) throws IOException { - if (rowNumber == 0) { + if ((rowNumber == 0) || isAdditionalHeader(rowNumber)) { super.writeColumnHeader(context, out, state, rowNumber, column); } else { out.writeText("Header Row: " + rowNumber + " Col: " + column); } }
Test
There are examples of additional headers in three views in the demo:
- "Tables > Frozen" contains examples of several headers defined by ControlProvider.
- In all columns except Name and the Selection column there should be two additional headers.
- In "Float" the maximum and minimum value is displayed.
- In "Float (no special configuration)" the average and the sum is shown.
- In all other columns the number of null values and the percentage of null values is shown.
- TL 6: "Tables > Tree Grid" contains examples of headers defined by TL script:
- In all columns except Name and the Selection column there should be two additional headers.
- In "Float" the maximum and minimum value is displayed.
- In "Float (no special configuration)" the average and the sum is shown.
- In all other columns the number of null values and the percentage of null values is shown.
- "Structures > Structures > Type Demo": If an "A" is displayed, the table "priorityTable" contains an additional header. In all columns except Name and the selection column, the number of null values should be displayed. This table serves as an example that additional headers are also displayed correctly in the form.