AnewtGridRenderer Class Reference

Renders data grids as XHTML in a fancy way. More...

List of all members.

Public Member Functions

 __construct ()
 Construct a new AnewtGridRenderer instance.
 add_column ($column)
 Add a column to the grid.
 add_count_column ($header_text=null, $initial_value=null)
 Add a counter column to the grid.
 show_column ($column_id)
 Make sure a column is shown in the output.
 hide_column ($column_id)
 Make sure a column is hidden from the output.
 highlight_column ($column_id, $unhighlight_others=true)
 Mark a single column for highlighting.
 visible_columns ()
 Return a list of columns that are visible using the current settings.
 add_row ($row)
 Add a row of data to the grid.
 add_rows ($rows)
 Convenience function to add a bunch of rows at once.
 set_rows ($rows)
 Set rows to the provided list.
 render ()
 Render the grid into a valid XHTML snippet.

Private Member Functions

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

Static Private Member Functions

static _cmp_column_order ($col1, $col2)
 Sort function that sorts AnewtGridColumns based on their 'order' property.

Private Attributes

 $_columns = array()
 List of columns.
 $_rows = array()
 List of data rows.


Detailed Description

Renders data grids as XHTML in a fancy way.

Some features:

These properties can be set to change the behaviour:

Definition at line 42 of file grid.lib.php.


Member Function Documentation

static AnewtGridRenderer::_cmp_column_order ( col1,
col2 
) [static, private]

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
Returns:
An integer than can be used for usort()

Definition at line 57 of file grid.lib.php.

AnewtGridRenderer::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:
AnewtGridColumn

Definition at line 96 of file grid.lib.php.

AnewtGridRenderer::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)

Definition at line 132 of file grid.lib.php.

AnewtGridRenderer::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.

Definition at line 154 of file grid.lib.php.

AnewtGridRenderer::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.

Definition at line 169 of file grid.lib.php.

AnewtGridRenderer::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 

Definition at line 185 of file grid.lib.php.

AnewtGridRenderer::visible_columns (  ) 

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

Returns:
A list of column objects.

Definition at line 210 of file grid.lib.php.

AnewtGridRenderer::_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.

Returns:
A number indicating the number of visible columns.

Definition at line 236 of file grid.lib.php.

AnewtGridRenderer::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:
AnewtGridCellRenderer::render_cell

AnewtGridRenderer::add_row

AnewtGridRenderer::set_rows

Definition at line 268 of file grid.lib.php.

AnewtGridRenderer::add_rows ( rows  ) 

Convenience function to add a bunch of rows at once.

Parameters:
$rows Array of row data
See also:
AnewtGridRenderer::add_row

AnewtGridRenderer::set_rows

Definition at line 283 of file grid.lib.php.

AnewtGridRenderer::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:
AnewtGridRenderer::add_row

AnewtGridRenderer::add_rows

Definition at line 304 of file grid.lib.php.

AnewtGridRenderer::render (  ) 

Render the grid into a valid XHTML snippet.

Returns:
XHTML string that can be used directly for output

Reimplemented from AnewtRenderer.

Definition at line 319 of file grid.lib.php.


The documentation for this class was generated from the following file:

Generated on Sun Aug 2 22:54:37 2009 for Anewt by  doxygen 1.5.9