class Grid (View source)

The Grid class to dynamically generate HTML tables.

This is currently a Joomla JGrid fork.

Constants

ROW_HEAD

ROW_FOOT

ROW_NORMAL

Methods

__construct(array $attribs = array())

Constructor for a Grid object

static Grid
create(array $attribs = array())

create

string
__toString()

Magic function to render this object as a table.

setTableAttributes(array $attribs = array(), bool $replace = false)

Method to set the attributes for a table-tag

array
getTableAttributes()

Get the Attributes of the current table

addColumn(string $name)

Add new column name to process

array
getColumns()

Returns the list of internal columns

deleteColumn(string $name)

Delete column by name

setColumns(array $columns)

Method to set a whole range of columns at once This can be used to re-order the columns, too

addRow(array $attribs = array(), int|bool $special = self::ROW_NORMAL)

Adds a row to the table and sets the currently active row to the new row

array
getRowAttributes()

Method to get the attributes of the currently active row

setRowAttributes(array $attribs)

Method to set the attributes of the currently active row

int
getActiveRow()

Get the currently active row ID

setActiveRow(int $id)

Set the currently active row

setRowCell(string $name, string $content, array $attribs = array(), bool $replace = true)

Set cell content for a specific column for the currently active row

array
getRow(int|bool $id = false)

Get all data for a row

array
getRows(int|bool $special = false)

Get the IDs of all rows in the table

deleteRow(int $id)

Delete a row from the object

string
toString()

Render the HTML table

Details

at line line 63
__construct(array $attribs = array())

Constructor for a Grid object

Parameters

array $attribs Associative array of attributes for the table-tag

at line line 75
static Grid create(array $attribs = array())

create

Parameters

array $attribs

Return Value

Grid

at line line 87
string __toString()

Magic function to render this object as a table.

Return Value

string

at line line 109
Grid setTableAttributes(array $attribs = array(), bool $replace = false)

Method to set the attributes for a table-tag

Parameters

array $attribs Associative array of attributes for the table-tag
bool $replace Replace possibly existing attributes

Return Value

Grid This object for chaining

at line line 130
array getTableAttributes()

Get the Attributes of the current table

Return Value

array Associative array of attributes

at line line 144
Grid addColumn(string $name)

Add new column name to process

Parameters

string $name Internal column name

Return Value

Grid This object for chaining

at line line 158
array getColumns()

Returns the list of internal columns

Return Value

array List of internal columns

at line line 172
Grid deleteColumn(string $name)

Delete column by name

Parameters

string $name Name of the column to be deleted

Return Value

Grid This object for chaining

at line line 195
Grid setColumns(array $columns)

Method to set a whole range of columns at once This can be used to re-order the columns, too

Parameters

array $columns List of internal column names

Return Value

Grid This object for chaining

at line line 213
Grid addRow(array $attribs = array(), int|bool $special = self::ROW_NORMAL)

Adds a row to the table and sets the currently active row to the new row

Parameters

array $attribs Associative array of attributes for the row
int|bool $special 1 for a new row in the header, 2 for a new row in the footer

Return Value

Grid This object for chaining

at line line 240
array getRowAttributes()

Method to get the attributes of the currently active row

Return Value

array Associative array of attributes

at line line 254
Grid setRowAttributes(array $attribs)

Method to set the attributes of the currently active row

Parameters

array $attribs Associative array of attributes

Return Value

Grid This object for chaining

at line line 268
int getActiveRow()

Get the currently active row ID

Return Value

int ID of the currently active row

at line line 282
Grid setActiveRow(int $id)

Set the currently active row

Parameters

int $id ID of the row to be set to current

Return Value

Grid This object for chaining

at line line 302
Grid setRowCell(string $name, string $content, array $attribs = array(), bool $replace = true)

Set cell content for a specific column for the currently active row

Parameters

string $name Name of the column
string $content Content for the cell
array $attribs Associative array of attributes for the td-element
bool $replace If false, the content is appended to the current content of the cell

Return Value

Grid This object for chaining

at line line 329
array getRow(int|bool $id = false)

Get all data for a row

Parameters

int|bool $id ID of the row to return

Return Value

array Array of columns of a table row

at line line 355
array getRows(int|bool $special = false)

Get the IDs of all rows in the table

Parameters

int|bool $special false for the standard rows, 1 for the header rows, 2 for the footer rows

Return Value

array Array of IDs

at line line 381
Grid deleteRow(int $id)

Delete a row from the object

Parameters

int $id ID of the row to be deleted

Return Value

Grid This object for chaining

at line line 411
string toString()

Render the HTML table

Return Value

string The rendered HTML table