Table Layout

Description

The TableLayoutWdg is the primary widget used to layout tabular data. It is primarily driven by the widget configuration. The TableLayoutWdg has the ability to display complex widgets inside each cell, to inline edit the data and to color code cells. It is the widget that is most often used to display information within the TACTIC.

Info

Name

Table Layout

Class

tactic.ui.panel.TableLayoutWdg

TACTIC Version Support

2.5.0 +

Required database columns

none

Implementation

The TableLayoutWdg makes use of "views" which are defined in the widget config for each project. When the Table is loaded as part of an interface, a view configuration is passed into it which defines which columns and widgets should be displayed in the view. Typically, these view configurations are automatically saved in the background when a user saves a view from within the TACTIC interface. The table itself provides the ability to add, remove, rearrange, resize and group columns which can then be saved out often as links in the sidebar.

The following shows a simplified version for an "asset tracking" view as saved in the background widget config.

<config>
  <asset_tracking layout="TableLayoutWdg" >
    <element name="preview" width="74px"/>
    <element name="asset_category_code" width="64px"/>
    <element name="code" width="61px"/>
    <element name="title" width="121.883px"/>
    <element name="description" width="276.75px"/>
    <element name="keywords" width="253.367px"/>
    <element name="general_checkin" width="27px"/>
    <element name="history" width="42px"/>
    <element name="task_edit" width="29px"/>
    <element name="task_status_edit" width="223.167px"/>
  </asset_tracking>
</config>

The widget configuration is an XML document. In this example, it defines an "asset_tracking" view with elements (preview, asset_category, code, title, description, keywords, etc...).

To draw what to display, TableLayoutWdg looks at the list of elements defined in the widget config and draws a column for each element. TACTIC then draws a row for each item that was either retrieved from a search, an expression or by supplied items. Each cell in the table represents an item being drawn by the defined element for a given column.

While the top widget configuration defines the list of elements to draw the columns, the exact definition of each element do not necessarily appear here. There are a number of views which define an element. Some of these elements may be defined inline or they may be defined elsewhere. There is a set hierarchy which the TableLayoutWdg looks for to find the definition of a particular element.

The hierarchy which TableLayoutWdg looks to find the definition for an element is as follows:

  1. the given type, view combination in the widget_config table

  2. the "definition" view for the given type in the widget_config table

  3. the predefined views for a given type (modules shipped with TACTIC will have predefined views for may of the items to ensure proper functioning of TACTIC even if there are no entries in the widget_config database)

  4. the "default_definition" for a given type as defined in the predefined views.

The third and fourth locations only apply to predefined types that are shipped with TACTIC. All custom types will only use the first two.

Options

search_type

Defines the type that this table will be displaying. It is used both for finding the appropriate widget config and for handling search (if necessary). Defaults to "table".

view

Defines the view that this table will displaying. It used to find the appropriate widget config to display the table.

do_search

By default, the TableLayoutWdg will handle the search itself. However, certain widgets may wish to turn this functionality off because they are supplying the search (internally used by ViewPanelWdg)

order_by

Add an explicit order by in the search

expression

Use an expression to drive the search. The expression must return items.

parent_key

Set a specific parent for the search

width

Define an initial overall width for the table

show_row_select

Flag to determine whether or not to show row_selection

show_gear

Flag to determine whether or not to show the gear menu.

show_insert

Flag to determine whether or not to show the insert button.

insert_mode

aux|inline|pop-up|none - set the insert mode of the table
search_limit An overriding search limit. A value < 0 means no limit affecting the search
config_xml Explicitly define the widget config
element_names Explicitly set the element names to be drawn

Advanced

Very often, the TableLayoutWdg is not used directly, but is used through the ViewPanelWdg, which combines the TableLayoutWdg with the SearchWdg. Using ViewPanelWdg will provide all the functionality in a table view

Using the TableLayoutWdg does provide a simpler view if the search is already known,

This simple example shows the login table and the objects are explicitly given.

from tactic.ui.panel import TableLayoutWdg
div = DivWdg()
table = TableLayoutWdg(search_type='sthpw/login', view='table')
sObjects = Search("sthpw/login").get_sObject()
table.set_sObjects(sObjects)
div.add(table)

An expression can be set for the search as well.

from tactic.ui.panel import TableLayoutWdg
div = DivWdg()
expression = "@SOBJECT(sthpw/login)"
table = TableLayoutWdg(search_type='sthpw/login', view='table',expression=expression)
div.add(table)

This example embeds the login table with a "table" view in a CustomLayoutWdg.

<config>
<login>
  <html>
    <h1>This is the login table</h1>
    <element name='login_table'/>
  </html>
  <element name='login_table'>
    <display class='tactic.ui.panel.TableLayoutWdg'>
      <search_type>sthpw/login</search_type>
      <view>table</view>
      <expression>@SOBJECT(sthpw/login)</expression>
    </display>
  </element>
</login>
</config>

The widget config views determine how the TableLayoutWdg draws itself. There are a few custom attributes that a view can define. The view can define many parts of how the TableLayoutWdg is displayed. The following hides the "insert" button and makes each of the cells non-editable. These attributes are useful for reports which are generally not editable.

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <simple insert='false' edit='false'>
    <element name="preview"/>
    <element name="code"/>
    <element name="name"/>
    <element name="description"/>
  </simple>
</config>