Top  | Previous | Next

Power Table

Description

The power table is a much more customizable version of the table component, and has many more features. The power table contains advanced features such as drag-and-drop rows, multi-column sorting, column filtering, and cell-spanning. Customization comes through extensive use of extension functions, which are available to configure how each cell of the table looks, how the headers look, etc.

 

Basic Usage

The basics are just like the classic table - you simply bind the table's "data" property to your data, most often by using a SQL query binding. Note that many of the options built into the classic table have been moved to extension functions in the power table.

 

Power Table Features

Multi-column sorting. To sort multiple columns, select the header of the first column, hold down the Control key, then select the header of the next column. Click on the header again to reverse the sort order, and click a third time to remove sorting on the column.
Column filtering. Columns can be temporarily hidden from view using column filtering. Right-click on the header of the table, and uncheck columns that you would like to hide. You can disable this feature by disabling the Column Chooser Menu property on the table.
Column reordering. You can switch the locations of columns on the table using column reordering. Drag the header of the column that you would like to move to a new location on the table. You can disable this feature by disabling the Columns Re-Orderable property on the table.
Cell spanning. A cell can be spanned across multiple columns and rows. Keep in mind that you must explicitly define the locations of cells that must be spanned. This means that if you would like to use cell spanning, any other table features that change how the table is displayed will be disabled automatically (such as sorting, column filtering and column reordering). Click on the Cell Span Data dataset to configure spanning. Within the dataset, add a row for each new span. The "row" column controls the row in the table where the span will start. The "column" column controls the column where the span will start. The "width" column controls how many columns the span will cover. The "height" column controls how many rows the span will cover. Adding a row where "row=4, column=1, width=2, height=3" results in a span starting on the fifth row of the table and the second column (using 0-based indexing). The span will cover the second and third columns in the row and will also cover two rows below the fifth row, as shown below.

 

cell-spanning

Drag and Drop. This feature allows you to drag rows from one power table to another power table. In order to perform drag and drop, you must implement the onRowsDropped() extension function on the destination table. This is so that you can adapt the data from one table to the other within the function. You must also enable the Row Dragging Enabled property on both tables. Example of an onRowsDropped() extension script for two power tables with identical columns:

 

def onRowsDropped(self, sourceTable, rows, rowData, dropIndexLocation):

    if self != sourceTable:

        destDataset = self.getData()

        pyRowData = system.dataset.toPyDataSet(rowData)

        # Loop thru all the rows that have been selected and dragged to the

        # destination table.

        for row in pyRowData:

            newRow = []

            for column in row:

                newRow.append(column)

            destDataset = system.dataset.addRow(destDataset, dropIndexLocation, newRow)

        # Adds the rows to the destination table.

        self.setData(destDataset)

        # Optional. Deletes the dragged rows from the source table.

        sourceDataset = system.dataset.deleteRows(sourceTable.getData(), rows)

        sourceTable.setData(sourceDataset)

    else:

        system.gui.messageBox("Dropping on to same table not supported")

        # To drop onto the same table, the new row indices must be calculated

        # for both the dropped and deleted rows, taking changes into account.

Properties

Appearance

Font

Font of text of this component

Scripting name

font

Data type

Font

Foreground Color

The foreground color of the component.

Scripting name

foreground

Data type

Color

Background Color

The background color of the component.

Scripting name

background

Data type

Color

Selection Background

The default background color of selected cells.

Scripting name

selectionBackground

Data type

Color

Selection Foreground

The default foreground color of selected cells.

Scripting name

selectionForeground

Data type

Color

Inter Cell Spacing

The space (in pixels) between the cells

Scripting name

interCellSpacing

Data type

Dimension

Flags

expert

Show Horizontal Grid Lines?

 

Scripting name

showHorizontalLines

Data type

boolean

Flags

expert

Show Vertical Grid Lines?

 

Scripting name

showVerticalLines

Data type

boolean

Flags

expert

Grid Line Color

The color used to draw grid lines.

Scripting name

gridColor

Data type

Color

Flags

expert

Header Visible

Allows for hiding of the table's header.

Scripting name

headerVisible

Data type

boolean

Header Font

Font of the table's header text

Scripting name

headerFont

Data type

Font

Antialias

Draw with antialias on? Makes text smoother

Scripting name

antialias

Data type

boolean

Flags

expert

Column Sizing

Represents column sizing and position to preserve user-selected ordering.

Scripting name

defaultColumnView

Data type

String

Flags

expert

Column Attributes Data

The dataset describing the column attributes.

Scripting name

columnAttributesData

Data type

Dataset

Flags

expert

Behavior

Row Dragging Enabled

Enables drag-and-drop re-ordering for table rows. Implementing the 'onRowsDropped' extension function is also required to have functional drag-and-drop.

Scripting name

rowDragEnabled

Data type

boolean

Auto Row Height

Enables automatic resizing of row height.

Scripting name

rowResizeEnabled

Data type

boolean

Row Height

If row resizing is disabled, this will set the height of all rows

Scripting name

rowHeight

Data type

int

Sorting Enabled

Enables automatic multi-column sorting by clicking and CTRL-clicking on the table header.

Scripting name

sortingEnabled

Data type

boolean

Column Resize Menu

Enables a right-click popup menu on the column headers with resizing options.

Scripting name

headerResizeMenus

Data type

boolean

Column Chooser Menu

Enables a right-click popup menu on the column headers with options to show and hide columns.

Scripting name

headerColumnChooserMenus

Data type

boolean

Columns Re-Orderable

Enables the re-ordering of columns by dragging the column headers

Scripting name

columnReorderingAllowed

Data type

boolean

Columns Resizable

Enables the resizing of columns by dragging the margins of the column headers

Scripting name

columnResizingAllowed

Data type

boolean

Auto-Resize Mode

Determines how the table resizes the columns

Scripting name

autoResizeMode

Data type

int

Values

4

All Columns

3

Last Column

1

Next Column

0

Off

2

Subsequent Columns

Selection Mode

This mode determines if only one row/cell/column can be selected at once, or single or multiple intervals

Scripting name

selectionMode

Data type

int

Values

0

Single

1

Single Interval

2

Multiple Interval

Row Selection Allowed

This flag is used in conjunction with the Column Selection Allowed flag to determine whether not whole-rows, whole-columns, or both (single-cells) are selectable.

Scripting name

rowSelectionAllowed

Data type

boolean

Column Selection Allowed

This flag is used in conjunction with the Row Selection Allowed flag to determine whether not whole-rows, whole-columns, or both (single-cells) are selectable.

Scripting name

columnSelectionAllowed

Data type

boolean

Non-Contiguous Selection

Enables totally non-contiguous selection in the table

Scripting name

nonContiguousCellSelection

Data type

boolean

Edit Click Count

The number of clicks required to start editing a cell.

Scripting name

clickCountToStart

Data type

int

Common

Name

The name of this component.

Scripting name

name

Data type

String

Flags

bindable

Enabled

If disabled, a component cannot be used.

Scripting name

componentEnabled

Data type

boolean

Visible

If disabled, the component will be hidden.

Scripting name

visible

Data type

boolean

Flags

bindable

Cursor

The mouse cursor to use when hovering over this component.

Scripting name

cursorCode

Data type

int

Values

0

Default

1

Crosshair

2

Text

3

Wait

12

Hand

13

Move

4

SW Resize

5

SE Resize

6

NW Resize

7

NE Resize

8

N Resize

9

S Resize

10

W Resize

11

E Resize

Data

Data

The data for this table

Scripting name

data

Data type

Dataset

Flags

bindable

Selected Column

The index of the first selected column, or -1 if none.

Scripting name

selectedColumn

Data type

int

Flags

bindable | expert

Selected Row

The index of the first selected row, or -1 if none.

Scripting name

selectedRow

Data type

int

Flags

bindable | expert

Cell Span Data

This dataset holds information about how cells in the table span multiple rows and/or columns. Incompatible with column sorting and re-ordering.

Scripting name

cellSpanData

Data type

Dataset

Flags

bindable | expert

Data Quality

The data quality code for any tag bindings on this component.

Scripting name

dataQuality

Data type

int

Flags

bindable | expert

Uncategorized

TestData

Toggle this property to fill in the table's data with random data.

Scripting name

test

Data type

boolean

Flags

expert

Properties Loading

The number of properties currently being loaded

Scripting name

propertiesLoading

Data type

int

Flags

bindable | read-only

Scripting

Events

The following event sets are fired by this component. See Component Event Handlers to learn more.

mouse
mouseMotion
propertyChange

 

Scripting Functions

getSelectedColumns()

 

Returns a list of ints representing the currently selected columns.

Parameters

none

Returns

int[]

getSelectedRows()

 

Returns a list of ints that represent the currently selected rows.

Parameters

none

Returns

int[]

print()

 

This specialized print function will paginate the table onto multiple pages.

This function accepts keyword-style invocation.

Keyword Args

fitWidth - If true, the table's width will be stretched to fit across one page's width. Rows will still paginate normally. If false, the table will paginate columns onto extra pages. (default = true) [optional]

headerFormat - A string to use as the table's page header. The substring "{0}" will be replaced with the current page number. (default = None) [optional]

footerFormat - A string to use as the table's page footer. The substring "{0}" will be replaced with the current page number. (default = "Page {0}") [optional]

showDialog - Whether or not the print dialog should be shown to the user. Default is true. [optional]

landscape - Used to specify portrait (0) or landscape (1) mode. Default is portrait (0). [optional]

Returns

boolean - True if the print job was successful.

setColumnWidth(column, width)

 

Used to set a column's width at runtime.

Parameters

int column

int width

Returns

nothing

Extension Functions

The power table has the following extension functions. See each function's doc string for usage details.

configureEditor()
configureHeaderStyle()
initialize()
onCellEdited()
onDoubleClick()
onPopupTrigger()
onRowsDropped()