AnewtGridRenderer class

Renders data grids as XHTML in a fancy way.

Class Overview

Renders data grids as XHTML in a fancy way.

Some features:

These properties can be set to change the behaviour:

Public Methods

__construct()

Construct a new AnewtGridRenderer instance.

add_column($column)

Add a column to the grid.

If no custom AnewtGridCellRenderer instances were previously added to this column, a default AnewtGridCellRenderer is created and used, resulting in a single string cell, which is the common (simple) case.

Parameters

$column

A AnewtGridColumn instance.

See also

add_count_column($header_text=null, $initial_value=null)

Add a counter column to the grid.

This is a convenience function that adds a column with id count and a AnewtCountGridCellRenderer with id count as the first column in the grid.

Parameters

$header_text

The header text to use (optional, defaults to empty string; leave null to use default)

$initial_value

The initial value (optional, defaults to standard numbering; leave null to use default)

show_column($column_id)

Make sure a column is shown in the output.

Column visibility defaults to true, but might have been disabled before.

Parameters

$column_id

The id of the column.

hide_column($column_id)

Make sure a column is hidden from the output.

Hidden columns will not be rendered, so any expensive getter operations will not be executed (this is a considerable speedup in some cases).

Parameters

$column_id

The id of the column.

highlight_column($column_id, $unhighlight_others=true)

Mark a single column for highlighting.

This method optionally disables the highlight property of all other columns.

Parameters

$column_id

The id of the column.

$unhighlight_others

visible_columns()

Return a list of columns that are visible using the current settings.

Return value

A list of column objects.

add_row($row)

Add a row of data to the grid.

The data can be anything except null. However, if you want to use default renderers (those suffice for most simple cases), you should use an AnewtContainer object or an associative array for the $data parameter, since those can be rendered by the default AnewtGridCellRenderer using the id of the cell renderer as the property name of the object or as the key of the array.

Parameters

$row

Any value representing the row data (but not null).

See also

add_rows($rows)

Convenience function to add a bunch of rows at once.

Parameters

$rows

Array of row data

See also

set_rows($rows)

Set rows to the provided list.

This means all existing rows will be discarded. This method does not check the rows for null values (which are not allowed).

Parameters

$rows

Array of row data

See also

render()

Render the grid into a valid XHTML snippet.

Return value

XHTML string that can be used directly for output

Private Static Methods

static _cmp_column_order($col1, $col2) [private] [static]

Sort function that sorts AnewtGridColumns based on their 'order' property.

This method is used as a callback for usort()

Parameters

$col1

AnewtGridColumn 1

$col2

AnewtGridColumn 2

Return value

An integer than can be used for usort()

Private Methods

_number_of_expanded_visible_columns() [private]

Calculate the total number of XHTML columns that will be used to render the output.

This depends on the number of cell renderers in each column.

Return value

A number indicating the number of visible columns.

Private Attributes

$_columns [private]

List of columns.

$_rows [private]

List of data rows.

Inheritance

Base Classes

Inherited members