--- title: "Vision - Power Table Scripting Functions" --- # Vision - Power Table Scripting Functions > This page details the various component and extension functions available for [Vision's Power Table component](power-table.md). ## Component Functions ### .getSelectedColumns() * Description * Returns a list of ints representing the currently selected columns. * Parameters * none * Return * Object of Integers - An object containing integers that represent the indices of the selected columns. Can be iterated over in a similar manner to a Python List. ### .getSelectedRows() * Description * Returns a list of ints representing the currently selected rows. * Parameters * none * Return * Object of Integers - An object containing integers that represent the indices of the selected rows. Can be iterated over in a similar manner to a Python List. ### .print([fitWidth] [, headerFormat] [, footerFormat] [, showDialog] [, landscape]) * Description * This specialized print function will paginate the table onto multiple pages.This function accepts keyword-style invocation. * Keyword Args * boolean **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] * String **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] * String **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] * boolean **showDialog** - Used to determine if the print dialog should be shown to the user. Default is true. [optional] * boolean **landscape** - Used to specify portrait (0) or landscape (1) mode. Default is portrait (0). [optional] * Return * boolean - True if the print job was successful. ### .setColumnWidth(column, width) * Description * Used to set a column's width at runtime. * Parameters * int **column** - Column to adjust. * int **width** - Width in pixels. * Return * None ## Extension Functions ### configureCell * Description * Provides a chance to configure the contents of each cell. Returns a dictionary of name-value pairs with the desired attributes. Available attributes (and their Java types) include: 'background' (color), 'border' (border), 'font' (font), 'foreground' (color), 'horizontalAlignment' (int), 'iconPath' (string), 'text' (string), 'toolTipText' (string), 'verticalAlignment' (int). You can also specify the attribute 'renderer', which is expected to be a javax.swing.JComponent which will be used to render the cell. * Parameters * Component **self** - A reference to the component that is invoking this function. * Object **value** - The value in the dataset at this cell. * string **textValue** - The text the table expects to display at this cell (may be overriden by including 'text' attribute returned in dictionary). * boolean **selected** - A boolean indicating whether this cell is currently selected. * int **rowIndex** - The index of the row in the underlying dataset. * int **colIndex** - The index of the column in the underlying dataset. * string **colName** - The name of the column in the underlying dataset. * int **rowView** - The index of the row, as it appears in the table view (affected by sorting). * int **colView** - The index of the column, as it appears in the table view (affected by column re-arranging and hiding). * Return * Dictionary of Attributes ### configureEditor * Description * Provides a chance to configure how each column is edited. Returns a dictionary of name-value pairs with desired editor attributes. Visual attributes to modify existing editors include: 'background', 'border', 'font', 'foreground', 'horizontalAlignment', 'toolTipText', and 'verticalAlignment'. If the attribute 'options' is specified, it is expected to be a list of tuples representing (value, label). The editor in this case will become a dropdown list.If the attribute 'editor' is specified, it is expected to be an instance of javax.swing.table.TableCellEditor, and other attribute will be ignored. The 'options' editor on the Power Table’s configureEditor Extension Function accepts a rowHeight key allowing you to change the height of items in the dropdown. For example: ```py return {'options': [(0, 'Option A'), (1, 'Option B')], 'rowHeight':100} ``` * Parameters * Component **self** - A reference to the component that is invoking this function * int **colIndex** - The index of the column in the underlying dataset * string **colName** - The name of the column in the underlying dataset * Return * Dictionary of name value pairs ### configureHeaderStyle * Description * Provides a chance to configure the style of each column header. Return a dictionary of name-value pairs with the designed attributes. Availible attributes include: 'background', 'border', 'font', 'foreground', 'horizontalAlignment', 'toolTipText', 'verticalAlignment' * Parameters * Component **self** - A reference to the component that is invoking this function * int **colIndex** - The index of the column in the underlying dataset * string **colName** - The name of the column in the underlying dataset * Return * Dictionary of name value pairs ### initialize * Description * Called when the window containing this table is opened, or the template containing it is loaded. Provides a chance to initialize the table further, for example, selecting a specific row. * Parameters * Component **self** - A reference to the component that is invoking this function * Return * None ### isCellEditable * Description * Returns a boolean that determines whether or not the current cell is editable. * Parameters * Component **self** - A reference to the component that is invoking this function. * int **rowIndex** - Index of the row that was edited, relative to the underlying dataset. * int **colIndex** - Index of the column that was edited, relative to the underlying dataset. * string **colName** - Name of the column in the underlying dataset. * Object **value** - The value at the cell location. * Return * boolean ### onCellEdited * Description * Called when the user has edited a cell in the table. It is up to the implementation of this function to alter the underlying data that drives the table. This might mean altering the dataset directly, or running a SQL UPDATE query to update data in the database. :::note If the script on this extension function causes the Power Table to lose focus, the cell commit will occur twice. For example, if system.vision.showConfirm() is called, then two confirmation boxes will appear. In cases where the script will cause the focus to switch between multiple objects, the script should be placed in a function, and wrapped in a call to [system.vision.invokeLater()](appendix/scripting-functions/system-vision/system-vision-invokeLater.md) ```py def myFunction(): """ Do your work here """ system.vision.showMessage("Assuming you don't change focus outside of this script\nYou will only see this message once per cell edit") system.vision.invokeLater(myFunction) ``` ::: * Parameters * Component **self** - A reference to the component that is invoking this function. * int **rowIndex** - Index of the row that was edited, relative to the underlying dataset. * int **colIndex** - Index of the column that was edited, relative to the underlying dataset. * string **colName** - Name of the column in the underlying dataset. * Object **oldValue** - The old value at the location, before it was edited. * Object **newValue** - The new value input by the user. * Return * None ### onMousePress * Description * Called when the user clicks on a table cell. * Parameters * Component **self** - A reference to the component that is invoking this function. * int **rowIndex** - Index of the row, starting at 0, relative to the underlying dataset. * int **colIndex** - Index of the column starting at 0, relative to the underlying dataset. * Object **value** - The value at the location clicked on. * MouseEvent **event** - The MouseEvent object that caused this click event. * Return * None ### onMouseRelease * Description * Called when the user releases the mouse button on a table cell. * Parameters * Component **self** - A reference to the component that is invoking this function. * int **rowIndex** - Index of the row, starting at 0, relative to the underlying dataset. * int **colIndex** - Index of the column starting at 0, relative to the underlying dataset. * Object **value** - The value at the location that the mouse is released on. * MouseEvent **event** - The MouseEvent object that caused this released event. * Return * None ### onMouseClick * Description * Called when the user clicks on a table cell. * Parameters * Component **self** - A reference to the component that is invoking this function. * int **rowIndex** - Index of the row, starting at 0, relative to the underlying dataset. * int **colIndex** - Index of the column starting at 0, relative to the underlying dataset. * Object **value** - The value at the location clicked on. * MouseEvent **event** - The MouseEvent object that caused this click event. * Return * None ### onDoubleClick * Description * Called when the user double-clicks on a table cell. * Parameters * Component **self** - A reference to the component that is invoking this function. * int **rowIndex** - Index of the row, starting at 0, relative to the underlying dataset. * int **colIndex** - Index of the column starting at 0, relative to the underlying dataset. * Object **value** - The value at the location clicked on. * MouseEvent **event** - The MouseEvent object that caused this double-click event. * Return * None ### onPopupTrigger * Description * Called when the user right-clicks on a table cell. This would be the appropriate time to create and display a popup menu. * Parameters * Component **self** - A reference to the component that is invoking this function. * int **rowIndex** - Index of the row, starting at 0, relative to the underlying dataset. * int **colIndex** - Index of the column starting at 0, relative to the underlying dataset. * string **colName** - Name of the column in the underlying dataset. * Object **value** - The value at the location clicked on. * MouseEvent **event** - The MouseEvent object that caused this popup trigger event * Return * None ### onRowsDropped * Description * Called when the user has dropped rows on this table. Note that the rows may have come from this table or another table. The source table must have dragging enabled. * Parameters * Component **self** - A reference to the component that is invoking this function. * Component **sourceTable** - A reference to the table that the rows were dragged and dropped in the same table. * list **rows** - An array of the rows indices that were dragged, in the order they were selected. * Dataset **rowData** - A dataset containing the rows that were dragged. * int **dropIndexLocation** - Row index where the rows were dropped. * Return * None