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:
-
the given type, view combination in the widget_config table
-
the "definition" view for the given type in the widget_config table
-
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)
-
the "default_definition" for a given sType as defined in the predefined views.
The third and fourth locations only apply to predefined sTypes that are shipped with TACTIC. All custom types will only use the first two.
Options
search_type |
Define the sType 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. |
insert_view |
Specify the path to a custom insert view. |
edit_view |
Specify the path to a custom edit view. |
ingest_custom_view |
Specify a custom layout view that Ingest Files menu option opens in a new tab. |
ingest_data_view |
Specify a view similar to edit view that defines any data to be saved with each ingested sobject. |
expression |
Specify an expression to drive the search. The expression must return items. e.g. @SEARCH(sthpw/note) or @SOBJECT(sthpw/note) |
config_xml |
Explicitly define the widget config. the kwarg view is preferred over this. |
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) - true, false. |
order_by |
Add an explicit order by in the search |
parent_key |
Set a specific parent for the search |
checkin_context |
Override the checkin context for Check-in New File - publish (default). |
checkin_type |
Override the checkin type for Check-in New File - auto, strict. |
width |
Define an initial overall width for the table |
show_gear |
Determine whether to show the gear menu - true, false. |
show_search |
Determine whether to show the search box - true, false. |
show_search_limit |
Determine whether to show the search limit - true, false. |
show_insert |
Determine whether to show the insert button - true, false. |
show_refresh |
Display the refresh button on the shelf - true, false. |
show_keyword_search |
Determine whether to show the Keyword search input - true, false. |
show_select |
Determine whether to show row_selection - true, false. |
show_shelf |
Determine whether to show the action shelf - true, false. |
show_layout_switcher |
Determine whether to show the layout switcher - true, false. |
show_column_manager |
Determine whether to show the column manager - true, false. |
show_collection_tool |
Determine whether to show the collection button - true, false. |
show_context_menu |
Determine whether to show the context menu - true, false. |
show_expand |
Determine whether to show the expand button - true, false. |
show_help |
Determine whether to show the help button - true, false. |
show_border |
Determine whether to show the table border - true, false. |
show_header |
Determine whether to show the table header - true, false. |
show_insert |
Determine whether to show the insert button - true, false. |
search_limit |
The number of items to show on each page. e.g. 20 A value < 0 means no limit affecting the search. |
search_limit_mode |
Determine if it displays top, bottom or both search limit - bottom, top, both |
mode |
Determine whether to draw with widgets or just use the raw data - widget, raw. |
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>