Book a Demo
Prev Next

Custom Table Artifact

The Custom Table artifact is a diagram object that displays custom data in a grid format similar to a spreadsheet. For example:

The benefits of using this element include:

  • Providing extra 'non-modeled' information on elements, diagrams or project management exactly where it is applicable, such as a SWAT Analysis or Capability Matrix
  • Providing such information in a convenient human-readable and - if appropriate - human-editable format
  • The ability to read and update data using scripts and Add-Ins

This feature is available in the Corporate, Unified and Ultimate Editions of Enterprise Architect, from Release 15.0.

Create a Custom Table

From the 'Dynamic Viewpoints' page of the Diagram Toolbox, drag the Custom Table icon onto a diagram.

The Table element is created on the diagram and in the Browser window.  On the diagram, click on the element to select it, then drag the borders of the element to expand it to a more comfortable size for editing.

Working with Custom Tables

To modify a Custom Table, it must first be placed into edit mode. To begin editing, right-click the Custom Table element on the diagram and select 'Edit Custom Table'. Alternatively, click on the element and press the Enter key or the F2 key.

While in edit mode you can modify and format the table contents. 

To exit edit mode, right-click on the element and choose the option 'Exit Edit'.  Alternatively, deselecting the table element (by clicking outside of the element, or by pressing the 'Esc' key) will also exit the edit mode.

Exiting edit mode will automatically save your changes.

  1. The Custom Table data content will automatically be saved in XML format into the element's 'data' property.
  2. The Custom Table row/cell formatting data will automatically be saved in XML format into the 'dataformat' property.

If you update a Custom Table element's properties by directly editing the XML, you can refresh the element in the diagram by right-clicking the element and selecting the option 'Refresh Custom Table'.

Operation

Description

See also

Define Grid Size

The new Custom Table element does not yet have a defined grid size.

  1. Right-click in the blank space in the body of the element and select the 'Set Grid Size...' option.
  2. In the 'Set Grid Size' dialog, type in the required numbers of rows and columns.
  3. Click on the OK button.

Columns are autosized to occupy the visual area of the Table element. Rows, however, default to a single line height.

Add More Columns

You have two options for adding further columns to the table:

  • Add a new column to the right hand end of the table - right click on the table and select the 'Add Column' option
  • Insert a column at a specific point in the table - right-click on a column and select the 'Insert Column' option and either 'Before Selected Column' or 'After Selected Column' as required

Add More Rows

You also have two options for adding rows to the table:

  • Add a new row to the bottom of the table - right-click on the table and select the 'Add Row' option; the row might not be visible without scrolling to it, but note that the 'Showing x - n of y items' counter in the bottom right of the element will be incremented
  • Insert a row at a specific point in the table - right-click on a row and select the 'Insert Row' option and either 'Above Selected Row' or 'Below Selected Row' as required; the inserted row has the default height of one line

Delete Columns or Rows

Right-click on a cell in the column or row and select 'Delete Selected Row' or 'Delete Selected Column'.

You cannot delete more than one row or column at a time, nor can you delete a row or column containing merged cells (even if they do not contain cells outside the row or column).

Copy Content

When you have data in the table, you can select to copy the content of either selected cells or the entire table to the clipboard, to paste into an external spreadsheet tool or text file.

Select the 'Copy to Clipboard' option and then either 'Selected' or 'All'.

Change Column Width

Click on a column cell and either drag the border of the column header cell to the required width, or right-click on the Table element and select the 'Set Column(s) Width' option. (To select multiple columns, press the Ctrl key as you select each column.)

If you select the 'Set Column(s) Width' option, the 'Set Column Width' dialog displays. Either type in the required width in pixels, or click on the arrows to increase or decrease the value by one pixel per click. Click on the OK button when you have entered the width.

Note that:

  • Column widths are confined by the width of the element; you cannot increase the width of a column indefinitely, as the width increase will be blocked prior to the point at which one of the columns will lose its visible presence on the Table
  • Manually setting a column width by dragging the header border adjusts the width of any unset columns by equal amounts; for example, in a three-column Table, increasing one column width by eight pixels will decrease the width of the other two columns by 4 pixels each
  • Setting a column width through the 'Set Column Width' dialog changes the width of any unset and manually set columns by equal amounts
  • Adjusting the size of the Table element will adjust the column widths within the Table in proportion to each other
  • Text strings will wrap in the width of the column

Change Row Height

If you want to increase or decrease the height of one or more rows by one line height, right-click on a cell in that row and select the 'Increase row lines' or 'Decrease row lines' option, as appropriate. (To select multiple rows, press the Ctrl key as you select each row.)

If you want to increase or decrease the height of one or more rows by several line heights, right-click on a cell in the selected row(s) and select the 'Set row(s) lines option'. The 'Set Row Lines' dialog displays.

Either type in the required height in lines, or click on the arrows to increase or decrease the value by one line per click. Click on the OK button to save the settings.

Note that:

  • Changing the height of one or more rows has no effect on the height of unselected rows in the Table
  • Increasing the height of a row can scroll other rows out of sight, beyond the borders of the Table element
  • If the text of a cell is more than can be displayed in the cell, the text scrolls out of sight beyond the top and bottom of the cell; in these situations, mouse-over the cell to display the full text in a pop-up field, or add more height to the row to accommodate the text

Format the Grid

You can perform operations to format the appearance of cells in the table, and of the table as a whole. Right-click on the table and select:

  • Show Grid Lines - to hide or display all lines separating cells; this does not hide those lines specifically displayed using the 'Set Cell(s) Border' option
  • Set Cell(s) Border - if 'Show Grid Lines' is toggled off and you have highlighted one or more cells, select the option for the required cell edge to display that edge on the cell(s):

         -  Top

         -  Right

         -  Bottom

         -  Left

         -  Reset Default (to hide the visible borders of the currently-selected cells)

    Note that the border width is fixed at 1px.

  • Set Grid Color - the 'Select item color' dialog displays; click on the 'Set Color' drop-down arrow and on the appropriate color in the palette, then click on the OK button to apply the color to either all cell borders in the table ('Show Grid Lines' on) or those specifically selected for display ('Set Cell(s) Border')
  • Merge Selected - (available if you have selected two or more cells by sweeping the cursor across them) the separate cells become one cell, with the formatting of the uppermost and/or leftmost cell; the selected cells must form a regular block - you cannot merge two cells on one line with one cell on the next line unless the cells form a rectangle
  • UnMerge Selected - the previously-merged cells reappear with their original dimensions, color, text and formatting

Add Text to a Cell

Double-click on the cell and start typing.

Alternatively, if you have copied text into the buffer, click twice on the cell, right-click and select the 'Paste' option. Note that formatting (even from another table cell) is not transferred in the copy.

Format Text

You can perform a number of operations to format the complete text of a cell. The options cannot operate on partial text strings in a cell. Note that these options take effect when you click off the cell.

Right-click on the cell and select the required option:

  • Horizontal Align Text - select the appropriate sub-option to align the text with the left, center or right of the cell (new cells default to left-aligned text)
  • Vertical Align Text - select the appropriate sub-option to align the text with the top, center or bottom of the cell (new cells default to center-aligned text)
  • Set Text Color - the 'Select item color' dialog displays; click on the 'Set Color' drop-down arrow and on the appropriate color in the palette, then click on the OK button
  • Set Background Color - (to set the background for the cell, whether or not it contains text) the 'Select item color' dialog displays; click on the 'Set Color' drop-down arrow and on the appropriate color in the palette, then click on the OK button
  • Toggle Bold Text - the text is changed to bold or back to normal

Using the Tagged Values

The simplest method for initially defining and populating the Custom Table is to use the context menu options. However, if you want to set up a number of tables of similar structure it becomes more efficient to copy the XML from the Tagged Values of one table to the Tagged Values of another, or to add a script to read and/or populate the tables. Each Tagged Value is a <memo> type that can contain a lengthy collection of XML definitions.

Tagged Value

Content

data

As you build up the grid, the basic structure is defined in this Tagged Value in XML, and as you add data values they are inserted into the appropriate lines of the structure definition. For example:

<?xml version="1.0"?>

<adhoctable>

<table>

<row>

<column>Heading 1</column>

<column>Heading 2</column>

<column>Heading 3</column>

<column>Heading 4</column>

<column>Heading 5</column>

</row>

<row>

<column>Rowname</column>

<column></column>

<column></column>

<column></column>

<column></column>

</row>

If you want to enter data directly into the XML in this Tagged Value, the 'Edit Custom Table' context menu must be off (you have selected the 'Exit Editing' option) and you should select the 'Refresh Custom Table' context menu option frequently to update the table image.

dataFormat

As you define the format and appearance of the grid, the definition is stored in XML in this Tagged Value. For example:

<?xml version="1.0"?>

<dataformat>

<style>

<grid rows="8" columns="5">

<gridcolor>16646398</gridcolor>

</grid>

<cells>

<cell row="0" col="0">

<bold>true</bold>

<txtcolor>255</txtcolor>

<borders>

<left>0</left>

<top>0</top>

<right>1</right>

<bottom>1</bottom>

</borders>

</cell>

<cell row="0" col="1">

<txtcolor>13434880</txtcolor>

<borders>

<left>0</left>

<top>0</top>

<right>1</right>

<bottom>1</bottom>

</borders>

</cell>

If you want to modify the definition directly in the XML in the Tagged Value, the 'Edit Custom Table' context menu must be off (you have selected the 'Exit Editing' option) and you should select the 'Refresh Custom Table' context menu option frequently to update the table image.

Custom Table Scripts

You can also associate a JavaScript script with your Custom Table element.  Typically, a script might be used to either read data from the table or update the data in the table.  Scripts are saved in the operation named 'script'.

Action

Description

Define a Script

To define or edit the script:

  • Click on the table element to select it
  • Choose the ribbon option 'Develop > Source Code > Behavior' (Alt+7)
  • Select the operation named 'script' in the left hand panel of the editor
  • Enter the script code in the right-panel of the editor

For detail on the methods available see the ElementGrid Class Help topic.

Run a Script

If an associated script has been defined for the table, it can be run by right-clicking the table while it is not in edit mode then choosing the option 'Run Custom Table Script'.

Learn more