SwatObject
└─SwatUIObject
└─SwatWidget
└─SwatControl
└─SwatView
└─SwatTableView
public class SwatTableView
extends SwatView
| Field Summary | |
|---|---|
| protected array | The columns of this table-view. |
| protected array | The columns of this table-view indexed by their unique identifier. |
| SwatTableViewOrderableColumn | The column of this table-view that the data in the model is sorted by by default if no sorting is happening. |
| protected array | Any extra rows that were appended to this view. |
| protected array | Grouping objects for this table view. |
| protected array | The groups of this table-view indexed by their unique identifier. |
| protected boolean | Whether or not this table view has an input row. |
| string | No records message text. |
| string | Optional content type for the no records message. |
| SwatTableViewOrderableColumn | The column of this table-view that data in the model is currently being sorted by. |
| protected array | The extra rows of this table-view indexed by their unique identifier. |
| protected array | Row column objects for this table view. |
| protected array | The row columns of this table-view indexed by their unique identifier. |
| boolean | Whether of not to display the tfoot element after the tbody element. |
| Fields inherited from Swat.SwatView | |
|---|---|
| checked_items, model, selections, selectors | |
| Constructor Summary | |
|---|---|
SwatTableView(string id) Creates a new table view. |
|
| Method Summary | |
|---|---|
| void | addChild(mixed child) Adds a child object. |
| void | appendColumn(SwatTableViewColumn column) Appends a column to this table-view. |
| void | appendGroup(SwatTableViewGroup group) Appends a grouping object to this table-view. |
| void | appendRow(SwatTableViewRow row) Appends a single row to this table-view. |
| void | appendSpanningColumn(SwatTableViewSpanningColumn column) Appends a spanning column object to this table-view. |
| SwatUIObject | copy(string id_suffix) Performs a deep copy of the UI tree starting with this UI object. |
| void | display() Displays this table-view. |
| protected void | Displays the contents of this view. |
| protected void | Displays any footer content for this table-view. |
| protected void | Displays the column headers for this table-view. |
| protected void | displayRow(mixed row, mixed next_row, integer count) Displays a single row. |
| protected void | displayRowColumns(mixed row, mixed next_row, integer count) Displays the columns for a row. |
| protected void | displayRowGroupFooters(mixed row, mixed next_row, integer count) Displays row group headers. |
| protected void | displayRowGroupHeaders(mixed row, mixed next_row, integer count) Displays row group headers. |
| protected void | displayRowMessages(mixed row) Displays a list of SwatMessage object for the given row. |
| protected void | displayRowSpanningColumns(mixed row, mixed next_row, integer count) Displays row spanning columns. |
| protected array | Gets the array of CSS classes that are applied to this table view. |
| SwatTableViewColumn | getColumn(string id) Gets a column in this table-view by the column's id. |
| integer | Gets the number of columns in this table-view. |
| array | Gets all columns of this table-view as an array. |
| array | Gets descendant states. |
| array | getDescendants(string class_name) Gets descendant UI-objects. |
| SwatUIObject | getFirstDescendant(string class_name) Gets the first descendant UI-object of a specific class. |
| SwatTableViewRow | getFirstRowByClass(string class_name) Gets the first extra row of the specified class from this table-view. |
| SwatTableViewGroup | getGroup(string id) Gets a group in this table-view by the group's id. |
| array | Gets all groups of this table-view as an array. |
| SwatHtmlHeadEntrySet | Gets the SwatHtmlHeadEntry objects needed by this table. |
| protected string | Gets inline JavaScript required by this table-view as well as any JavaScript required by columns and/or rows. |
| array | Gathers all messages from this table-view. |
| SwatTableViewRow | getRow(string id) Gets a row in this table-view by the row's id. |
| protected string | getRowClassString(mixed row, integer count) Gets CSS class string for the XHTML tr tag. |
| protected array | getRowClasses(mixed row, integer count) Gets CSS classes for the XHTML tr tag. |
| array | getRowsByClass(string class_name) Gets all the extra rows of the specified class from this table-view. |
| SwatTableViewSpanningColumn | getSpanningColumn(string id) Gets a spanning column in this table-view by the spanning column's id. |
| array | Gets all spanning columns of this table-view as an array. |
| integer | Gets the number of visible columns in this table-view. |
| array | Gets all visible columns of this table-view as an array. |
| integer | Gets how many XHTML table columns the visible column objects of this table-view object span on display. |
| boolean | hasColumn(string id) Returns true if a column with the given id exists within this table-view. |
| boolean | hasGroup(string id) Returns true if a group with the given id exists within this table-view. |
| protected void | Whether this table has a header to display. |
| boolean | Gets whether or not this table-view has any messages. |
| boolean | hasRow(string id) Returns true if a row with the given id exists within this table-view. |
| SwatTableViewSpanningColumn | hasSpanningColumn(mixed id) Returns true if a spanning column with the given id exists within this table-view. |
| void | init() Initializes this table-view. |
| protected void | insertColumn(SwatTableViewColumn column, SwatTableViewColumn reference_column, boolean after) Helper method to insert columns into this table-view. |
| void | insertColumnAfter(SwatTableViewColumn column, SwatTableViewColumn reference_column) Inserts a column after an existing column in this table-view. |
| void | insertColumnBefore(SwatTableViewColumn column, SwatTableViewColumn reference_column) Inserts a column before an existing column in this table-view. |
| protected void | insertRow(SwatTableViewRow row, SwatTableViewRow reference_row, boolean after) Helper method to insert rows into this table-view. |
| void | insertRowAfter(SwatTableViewRow row, SwatTableViewRow reference_row) Inserts a row after an existing row in this table-view. |
| void | insertRowBefore(SwatTableViewRow row, SwatTableViewRow reference_row) Inserts a row before an existing row in this table-view. |
| void | process() Processes this table-view. |
| protected boolean | rowHasMessage(mixed row) Whether any of the columns in the row has a message. |
| void | setDefaultOrderbyColumn(mixed column, integer direction, SwatTableViewOrderableColumn the) Sets a default column to use for ordering the data of this table-view. |
| void | setDescendantStates(array states) Sets descendant states. |
| protected void | validateColumn(SwatTableViewColumn column) Ensures a column added to this table-view is valid for this table-view. |
| protected void | validateGroup(SwatTableViewGroup group) Ensures a group added to this table-view is valid for this table-view. |
| protected void | validateRow(SwatTableViewRow row) Ensures a row added to this table-view is valid for this table-view. |
| Methods inherited from Swat.SwatView | |
|---|---|
| addSelector, getSelection, init, setSelection | |
| Methods inherited from Swat.SwatControl | |
|---|---|
| addMessage, getNote, printWidgetTree | |
| Methods inherited from Swat.SwatWidget | |
|---|---|
| addCompositeWidget, addMessage, confirmCompositeWidgets, copy, createCompositeWidgets, display, displayHtmlHeadEntries, getCSSClassNames, getCompositeWidget, getCompositeWidgets, getFocusableHtmlId, getHtmlHeadEntrySet, getMessages, hasMessage, init, isDisplayed, isInitialized, isProcessed, isSensitive, printWidgetTree, process, replaceWithContainer | |
| Methods inherited from Swat.SwatUIObject | |
|---|---|
| addComment, addJavaScript, addStyleSheet, addTangoAttribution, copy, getCSSClassNames, getCSSClassString, getFirstAncestor, getHtmlHeadEntrySet, getInlineJavaScript, getUniqueId, isVisible | |
protected array $columns = array()
The columns of this table-view
protected array $columns_by_id = array()
The columns of this table-view indexed by their unique identifier
A unique identifier is not required so this array does not necessarily contain all columns in the view. It serves as an efficient data structure to lookup columns by their id.
The array is structured as id => column reference.
public SwatTableViewOrderableColumn $default_orderby_column = null
The column of this table-view that the data in the model is sorted by by default if no sorting is happening
Setting this directly usually won't do what you want. Use the
SwatTableView::setDefaultOrderbyColumn() method instead.
If this is null then the default order of data in the model is some implicit order that the user cannot see. This results in tri-state column headers.
If this is set then the data ordering is always explicit and visible to the user. This results in bi-state column headers.
protected array $extra_rows = array()
Any extra rows that were appended to this view
This array does not include rows that are displayed based on this table-view's model.
protected array $groups = array()
Grouping objects for this table view
protected array $groups_by_id = array()
The groups of this table-view indexed by their unique identifier
A unique identifier is not required so this array does not necessarily contain all groups in the view. It serves as an efficient data structure to lookup groups by their id.
The array is structured as id => group reference.
protected boolean $has_input_row = false
Whether or not this table view has an input row
Only one input row is allowed for each table-view.
public string $no_records_message = ''
No records message text
A message to show if the table view has no records to display. If null, no message is displayed.
public string $no_records_message_type = 'text/plain'
Optional content type for the no records message
Default text/plain, use text/xml for XHTML fragments.
public SwatTableViewOrderableColumn $orderby_column
The column of this table-view that data in the model is currently being sorted by
If no sorting is currently happening, this can be null. Alternatively, this can be set to a SwatTableViewOrderableColumn and the column itself may be set to no sorting.
protected array $rows_by_id = array()
The extra rows of this table-view indexed by their unique identifier
A unique identifier is not required so this array does not necessarily contain all extra rows in the view. It serves as an efficient data structure to lookup extra rows by their id.
The array is structured as id => row reference.
protected array $spanning_columns = array()
Row column objects for this table view
protected array $spanning_columns_by_id = array()
The row columns of this table-view indexed by their unique identifier
A unique identifier is not required so this array does not necessarily contain all row columns in the view. It serves as an efficient data structure to lookup row columns by their id.
The array is structured as id => column reference.
public boolean $use_invalid_tfoot_ordering = false
Whether of not to display the tfoot element after the tbody element
If this flag is set to true, the tfoot element will be displayed after the tbody element. This is invalid XHTML but fixes a number of rendering bugs in various browsers. This flag defaults to false.
When browser support for tfoot is better, this property will be deprecated. This property is not recommended for use unless you are experiencing browser bugs in your table views.
public SwatTableView(string id)
Creates a new table view
id - a non-visible unique id for this widget.public void addChild(mixed child)
Adds a child object
This method fulfills the SwatUIParent interface. It is used
by SwatUI when building a widget tree and should not need to be
called elsewhere.
To add columns, rows, or a grouping to a table-view, use
SwatTableView::appendColumn(),
SwatTableView::appendRow(),
or SwatTableView::appendGroup().
child - a reference to a child object to add.public void appendColumn(SwatTableViewColumn column)
Appends a column to this table-view
column - the column to append.public void appendGroup(SwatTableViewGroup group)
Appends a grouping object to this table-view
A grouping object affects how the data in the table model is displayed in this table-view. With a grouping, rows are split into groups with special group headers above each group.
Multiple groupings may be added to table-views.
group - the table-view grouping to append to this table-view.public void appendRow(SwatTableViewRow row)
Appends a single row to this table-view
Rows appended to table-views are displayed after all the data from the table-view model is displayed.
row - the row to append.public void appendSpanningColumn(SwatTableViewSpanningColumn column)
Appends a spanning column object to this table-view
column - the table-view spanning column to use for this table-view.public SwatUIObject copy(string id_suffix)
Performs a deep copy of the UI tree starting with this UI object
id_suffix - optional. A suffix to append to copied UI objects in the UI tree.public void display()
Displays this table-view
The table view is displayed as an XHTML table.
protected void displayBody()
Displays the contents of this view
The contents reflect the data stored in the model of this table-view. Things like row highlighting are done here.
Table rows are displayed inside a
XHTML tag.protected void displayFooter()
Displays any footer content for this table-view
Rows in the footer are outputted inside a
HTML tag.protected void displayHeader()
Displays the column headers for this table-view
Each column is asked to display its own header.
Rows in the header are outputted inside a HTML tag.
Displays a single row The contents reflect the data stored in the model of this table-view.
Things like row highlighting are done here. Displays the columns for a row Displays row group headers Displays row group headers Displays a list of Displays row spanning columns Gets the array of CSS classes that are applied to this table view Gets a column in this table-view by the column's id Gets the number of columns in this table-view Gets all columns of this table-view as an array Gets descendant states Retrieves an array of states of all stateful UI-objects in the widget
subtree below this table-view. Gets descendant UI-objects Gets the first descendant UI-object of a specific class Gets the first extra row of the specified class from this table-view Unlike the Gets a group in this table-view by the group's id Gets all groups of this table-view as an array Gets the SwatHtmlHeadEntry objects needed by this table Gets inline JavaScript required by this table-view as well as any
JavaScript required by columns and/or rows. Column JavaSscript is placed before extra row JavaScript. Gathers all messages from this table-view Gets a row in this table-view by the row's id Gets CSS class string for the XHTML tr tag Gets CSS classes for the XHTML tr tag Gets all the extra rows of the specified class from this table-view Gets a spanning column in this table-view by the spanning column's id Gets all spanning columns of this table-view as an array Gets the number of visible columns in this table-view Gets all visible columns of this table-view as an array Gets how many XHTML table columns the visible column objects of this
table-view object span on display Returns true if a column with the given id exists within this
table-view Returns true if a group with the given id exists within this table-view Whether this table has a header to display Each column is asked whether is has a header to display. Gets whether or not this table-view has any messages Returns true if a row with the given id exists within this table-view Returns true if a spanning column with the given id exists within this table-view Initializes this table-view This initializes all columns, extra rows and groupsin this table-view. Helper method to insert columns into this table-view Inserts a column after an existing column in this table-view Inserts a column before an existing column in this table-view Helper method to insert rows into this table-view Inserts a row after an existing row in this table-view Inserts a row before an existing row in this table-view Processes this table-view Whether any of the columns in the row has a message Sets a default column to use for ordering the data of this table-view Sets descendant states Sets states on all stateful UI-objects in the widget subtree below this
table-view. Ensures a column added to this table-view is valid for this table-view Ensures a group added to this table-view is valid for this table-view Ensures a row added to this table-view is valid for this table-view
displayRow
protected void displayRow(mixed row, mixed next_row, integer count)
row - the row to display.next_row - the next row that will be displayed. If there is no next row, this is null.count - the ordinal position of the current row. Starts at one.
displayRowColumns
protected void displayRowColumns(mixed row, mixed next_row, integer count)
row - the row to display.next_row - the next row that will be displayed. If there is no next row, this is null.count - the ordinal position of the current row. Starts at one.
displayRowGroupFooters
protected void displayRowGroupFooters(mixed row, mixed next_row, integer count)
row - the row to display.next_row - the next row that will be displayed. If there is no next row, this is null.count - the ordinal position of the current row. Starts at one.
displayRowGroupHeaders
protected void displayRowGroupHeaders(mixed row, mixed next_row, integer count)
row - the row to display.next_row - the next row that will be displayed. If there is no next row, this is null.count - the ordinal position of the current row. Starts at one.
displayRowMessages
protected void displayRowMessages(mixed row)
SwatMessage object for the given row
row - the row for which to display messages.
displayRowSpanningColumns
protected void displayRowSpanningColumns(mixed row, mixed next_row, integer count)
row - the row to display.next_row - the next row that will be displayed. If there is no next row, this is null.count - the ordinal position of the current row. Starts at one.
getCSSClassNames
protected array getCSSClassNames()
getColumn
public SwatTableViewColumn getColumn(string id)
id - the id of the column to get.
getColumnCount
public integer getColumnCount()
getColumns
public array getColumns()
getDescendantStates
public array getDescendantStates()
getDescendants
public array getDescendants(string class_name)
class_name - optional class name. If set, only UI-objects that are instances of $class_name are returned.
getFirstDescendant
public SwatUIObject getFirstDescendant(string class_name)
class_name - class name to look for.
getFirstRowByClass
public SwatTableViewRow getFirstRowByClass(string class_name)
SwatUIParent::getFirstDescendant() method, this
method only checks this table-view and does not check the child objects
of this table-view.
class_name - the class name to filter by.
getGroup
public SwatTableViewGroup getGroup(string id)
id - the id of the group to get.
getGroups
public array getGroups()
getHtmlHeadEntrySet
public SwatHtmlHeadEntrySet getHtmlHeadEntrySet()
getInlineJavaScript
protected string getInlineJavaScript()
getMessages
public array getMessages()
getRow
public SwatTableViewRow getRow(string id)
id - the id of the row to get.
getRowClassString
protected string getRowClassString(mixed row, integer count)
row - a data object containing the data to be displayed in this row.count - the ordinal position of this row in the table.
getRowClasses
protected array getRowClasses(mixed row, integer count)
row - a data object containing the data to be displayed in this row.count - the ordinal position of this row in the table.
getRowsByClass
public array getRowsByClass(string class_name)
class_name - the class name to filter by.
getSpanningColumn
public SwatTableViewSpanningColumn getSpanningColumn(string id)
id - the id of the row to get.
getSpanningColumns
public array getSpanningColumns()
getVisibleColumnCount
public integer getVisibleColumnCount()
getVisibleColumns
public array getVisibleColumns()
getXhtmlColspan
public integer getXhtmlColspan()
hasColumn
public boolean hasColumn(string id)
id - the unique identifier of the column within this table view to check the existance of.
hasGroup
public boolean hasGroup(string id)
id - the unique identifier of the group within this table- view to check the existance of.
hasHeader
protected void hasHeader()
hasMessage
public boolean hasMessage()
hasRow
public boolean hasRow(string id)
id - the unique identifier of the row within this table-view to check the existance of.
hasSpanningColumn
public SwatTableViewSpanningColumn hasSpanningColumn(mixed id)
init
public void init()
insertColumn
protected void insertColumn(SwatTableViewColumn column, SwatTableViewColumn reference_column, boolean after)
column - the column to insert.reference_column - optional. An existing column within this table-view to which the inserted column is relatively positioned. If not specified, the column is inserted at the beginning or the end of this table-view's list of columns.after - optional. If true and a reference column is specified, the column is inserted immediately before the reference column. If true and no reference column is specified, the column is inserted at the beginning of the column list. If false and a reference column is specified, the column is inserted immediately after the reference column. If false and no reference column is specified, the column is inserted at the end of the column list. Defaults to false.
insertColumnAfter
public void insertColumnAfter(SwatTableViewColumn column, SwatTableViewColumn reference_column)
column - the column to insert.reference_column - the column after which the column will be inserted.
insertColumnBefore
public void insertColumnBefore(SwatTableViewColumn column, SwatTableViewColumn reference_column)
column - the column to insert.reference_column - the column before which the column will be inserted.
insertRow
protected void insertRow(SwatTableViewRow row, SwatTableViewRow reference_row, boolean after)
row - the row to insert.reference_row - optional. An existing row within this table-view to which the inserted row is relatively positioned. If not specified, the row is inserted at the beginning or the end of this table-view's list of extra rows.after - optional. If true and a reference row is specified, the row is inserted immediately before the reference row. If true and no reference row is specified, the row is inserted at the beginning of the extra row list. If false and a reference row is specified, the row is inserted immediately after the reference row. If false and no reference row is specified, the row is inserted at the end of the extra row list. Defaults to false.
insertRowAfter
public void insertRowAfter(SwatTableViewRow row, SwatTableViewRow reference_row)
row - the row to insert.reference_row - the row after which the row will be inserted.
insertRowBefore
public void insertRowBefore(SwatTableViewRow row, SwatTableViewRow reference_row)
row - the row to insert.reference_row - the row before which the row will be inserted.
process
public void process()
rowHasMessage
protected boolean rowHasMessage(mixed row)
row - the data object to use to check the column for messages.
setDefaultOrderbyColumn
public void setDefaultOrderbyColumn(mixed column, integer direction, SwatTableViewOrderableColumn the)
the - column in this view to use for default orderingdirection - the default direction of the ordered column.
setDescendantStates
public void setDescendantStates(array states)
states - an array of UI-object states with UI-object identifiers as array keys.
validateColumn
protected void validateColumn(SwatTableViewColumn column)
column - the column to check.
validateGroup
protected void validateGroup(SwatTableViewGroup group)
group - the group to check.
validateRow
protected void validateRow(SwatTableViewRow row)
row - the row to check.
silverorange Code
A widget to display data in a tabular form
Records in this table-view's model may be selected by the user by adding a view-selector to this table-view. See
SwatViewfor details on how to useSwatViewSelectorobjects.