BackPrevious Page Next PageNext

Modifying Tables

Editing a table with wizard

Sorting the detail data of a table

Inserting columns and rows in a table

Converting the columns in a table

Aggregating on the detail columns in a table

Showing/Hiding the summaries in a table

Formatting the cells in a table

Resizing the columns and rows in a table

Showing, hiding and deleting the columns/rows in a table

For any table in a report, you can further modify it at any time. For example you can change the data displayed in the table, summarize the data in a detail column of the table, and so on.

Tip: Some table operations require to use the shortcut menu on table cells, however when a table cell is entirely occupied by another object, it would be difficult to access its shortcut menu. In this case, you can resize the object in the cell first, then in the Report Inspector, select the node representing the cell that holds the object to select the cell itself, after that you can right-click on the blank area in the cell to get the shortcut menu.

Editing a table with wizard

Once a table has been created, you can further modify it by accessing its shortcut menu wizard which is composed by a set of screens that are similar to the wizard screens used to create the table. For example, you can change the data used by the table, edit the groups in the table, and so on.

  1. Right-click the table and select Table Wizard from the shortcut menu to display the Table Wizard.
  2. In the Data screen, specify a new data source for the table if required.
  3. In the Display screen, specify the detail fields to display in the table. Use the button Replace button to replace any current field. Click the Sort Fields By button to specify in which manner to sort the detail values.
  4. In the Group screen, specify the criteria for grouping data in the table.
  5. In the Style screen, select the style you want to apply to the table.
  6. Click Finish to accept the changes.

For more detailed information about defining a table, see Inserting Tables in a Report.

Sorting the detail data of a table

By default, the detail records in a table are displayed randomly; they are displayed in the order they are returned from the fetch operation. You can specify that JReport sort the records in a table, and also within the groups in the table if any.

  1. When creating or editing a table with the table wizard, click the Sort Fields By button in the Display screen. The Sort Fields By dialog appears.

    Sort Fields By dialog

  2. From the Resources box, select a field as the sort-by field and click Add button or drag and drop it to the right box.
  3. From the drop-down list in the Sort column, specify in which manner to sort the field, Ascend or Descend.
  4. Add more sort-by fields and specify the sort manner of each field using the same way. Click Move up button or Move down button to adjust the order of the sort-by fields, which will determine the sort priority of the fields at runtime. If a sort-by field is not required, select it and click Remove button or drag and drop it to the Resources box.
  5. Click OK to accept the sort settings.

    For example, if a table displays the detail fields for product quantity and cost and you want to sort the detail values first by quantity ascending and then cost descending. You can specify the sort manner as follows:

    Sort By Fields

    And the results will be:

    Sort Results

Note: The following SQL type of data cannot be sorted: Db.SQL_BINARY, Db.SQL_BLOB, Db.SQL_CLOB, Db.SQL_LONGVARCHAR, Db.SQL_LONGVARBINARY, Db.SQL_VARBINARY and Db.SQL_OTHER.

Inserting columns and rows in a table

Besides using the table wizard to create the columns and rows in a table, you can also insert columns and rows directly using the Insert Column/Row feature. A table can contain the following types of columns: group columns, detail columns, summary columns and common columns.

To insert a group column:

  1. Select the table or a column in the table, right-click it, then click Insert > Group Column on the shortcut menu. The Insert Group Column dialog appears, with the existing groups the table contains listed in an indented structure in the right box. You can edit the groups if you want.

    Insert Group Column

  2. In the right box, select the group level of the new group column by selecting Table or an existing group, then select a data field in the Resources box as the group-by field and click Add button or drag and drop it to the right box.
  3. In the Sort column, set the sort manner of groups at this group level.
  4. Specify the position of the group-by field in the table:
  5. If the table is created using a query resource, you can also specify the following:
  6. Repeat the above steps to add more group columns if required. You can make use of the Move Up button and Move Down button buttons to adjust the group levels.
  7. Click OK to insert the group columns.

To insert a detail column:

  1. Select the table or a column in the table, right-click it, then click Insert > Detail Column on the shortcut menu. The Insert Detail Column dialog appears.

    Insert Detail Column dialog

  2. Select the data field you want to use for the detail column.
  3. Click OK. A new detail column is inserted in the table and where it is placed depends on the following: if you use the column shortcut menu to insert the column, the new column is placed before the selected column; if you use the table shortcut menu to insert the column, it is placed after the last detail column, or as the last column in the table when there is no detail column.

To insert a summary column:

  1. Select the table or a column in the table, right-click it, then click Insert > Summary Column on the shortcut menu. The Insert Summary Column dialog appears.

    Insert Summary Column dialog

  2. Select the data field you want to use for the summary column.
  3. Click OK. A new summary column is inserted in the table which calculates data as follows:

    Where the new summary column is placed in the table depends on the following: if you use the column shortcut menu to insert the column, the new column is placed before the selected column; if you use the table shortcut menu to insert the column, it is placed after the last summary column, or as the last column in the table when there is no summary column.

To insert a common column:

You can then drag the required data fields from the Data panel or objects allowed for table cell from the Components panel into the column.

To insert a row:

  1. Select a cell or a row in the table, right-click it and then click Insert on the shortcut menu.
  2. In the Insert dialog, specify where the row will be inserted, above or below the selected cell.

    Insert

  3. Click OK. A new row of the same type is then inserted into the table according to the specified position. You can drag the required data fields from the Data panel or objects allowed for table cell from the Components panel into the row.

Converting the columns in a table

You can convert the group columns into detail columns. For a detail column, when the field in it can be used as group-by field, you can also convert it to a group column.

To convert a group column into a detail column:

Select the group column, right-click it, and select Convert to Detail from the shortcut menu, then the conversion is done.

To convert a detail column into a group:

  1. Select the detail column you want to convert, right-click it and select Convert to Group from the shortcut menu (the menu option is disabled when the field in the selected detail column has already been used as group-by field in the table).
  2. In the Select Group Position dialog, specify the position for the newly converted group-by field.

    Select Group Position

  3. Click OK to save the changes.

Aggregating on the detail columns in a table

You can calculate data based on any detail column in a table if required.

  1. Right-click the detail column and select Aggregate On from the shortcut menu. The Aggregate On dialog appears.

    Aggregate On

  2. From the Aggregate Function drop-down list, specify the function to calculate the field in the detail column.
  3. Specify the Group By option.
  4. Click OK. Data in the detail column will be calculated based on the group-by setting using the specified function.

Then:

Showing/Hiding the summaries in a table

When creating or editing a summary table via the table wizard in a web report or library component, once you have added any summary on its table header/footer or group header/footer, after the table is generated the Show Summary Field command will be activated on the shortcut menu of all the summary columns in the table. You can use the menu command to show or hide the summaries in the headers/footers.

  1. Right-click the summary column that contains the required summary.
  2. From the Show Summary Field submenu select/deselect the corresponding table/group header/footer to show/hide the summary on the specified locations.

    The summary will be placed in the intersection of its summary column and the table/group headers/footers.

Formatting the cells in a table

Resizing the columns and rows in a table

You have the following ways to resize the columns/rows in a table:

Showing, hiding and deleting the columns/rows in a table

To specify which columns you want to show in a table:

  1. Right-click the table and select Show Column from the shortcut menu. The Show Column dialog appears.

    Show Column

  2. All the columns in the table are listed, with text in cells of the table header panel representing corresponding columns. By default, the columns are listed according to their order in the table. Check Auto Sort if you want them to be listed alphabetically.
  3. Check the checkboxes ahead of the columns you want to show.
  4. Click OK to accept the changes.

To hide a table row:

Select the row, right-click it, and select Hide from the shortcut menu.

To hide a table column:

To delete a column/row:

Note: When a table is created, by default its structure is fixed and no row can be deleted. If you want to delete a row, you need to insert a same row first by using the shortcut menu, then you can delete the original row.

BackPrevious Page Next PageNext