Structures_DataGrid::addColumn

Structures_DataGrid::addColumn() – Add a column, with optional position

Synopsis

require_once 'Structures/DataGrid.php';

mixed Structures_DataGrid::addColumn ( &$column , string $position = 'last' , string $relativeTo = null , object $column )

Description

This package is not documented yet.

Parameter

&$column

string $position

One of: "last", "first", "after" or "before" (default: "last")

string $relativeTo

The name (label) or field name of the relative column, if $position is "after" or "before"

object $column

The Structures_DataGrid_Column object (reference to)

Return value

returns PEAR_Error on failure, void otherwise

Throws

throws no exceptions thrown

Examples

Adding a simple column

<?php
$datagrid 
=& new Structures_DataGrid();
$column = new Structures_DataGrid_Column('Title''title''title', array('align' => 'center'), 'N/A'null);
$datagrid->addColumn($column);
?>

Note

This function can not be called statically.

Constructor (Previous) Attach an already instantiated Rendering driver (Next)
Last updated: Thu, 23 Oct 2014 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

Note by: pierre2543@hotmail.com
If you are binding with a datasource and also want to add a column, make sure you call generateColumns() prior to adding your custom column. If you don't, none of the columns from the datasource will appear in your output.

Here's an example:
$dataobject = new DO_Task();
$datagrid =& new Structures_DataGrid(10);
$datagrid->bind($dataobject);
$datagrid->generateColumns(); //important!!
$datagrid->addColumn(new Structures_DataGrid_Column(
'Actions',
null,
null,
null,
null,
array('actionColumnCallback'),
'last'
));

$output = $datagrid->getOutput();

// Print rendering error if any
if (PEAR::isError($output))
echo $output->getMessage();
else
echo $output;