class JGrid

JGrid class to dynamically generate HTML tables

Methods

__construct( array $options = array())

Constructor for a JGrid object

string
__toString()

Magic function to render this object as a table.

setTableOptions( array $options = array(), bool $replace = false)

Method to set the attributes for a table-tag

array
getTableOptions()

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 $options = array(), int $special = false)

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

array
getRowOptions()

Method to get the attributes of the currently active row

setRowOptions( array $options)

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 $option = array(), bool $replace = true)

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

array
getRow( int $id = false)

Get all data for a row

array
getRows( int $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

__construct( array $options = array())

Constructor for a JGrid object

Parameters

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

string __toString()

Magic function to render this object as a table.

Return Value

string

JGrid setTableOptions( array $options = array(), bool $replace = false)

Method to set the attributes for a table-tag

Parameters

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

Return Value

JGrid This object for chaining

array getTableOptions()

Get the Attributes of the current table

Return Value

array Associative array of attributes

JGrid addColumn( string $name)

Add new column name to process

Parameters

string $name Internal column name

Return Value

JGrid This object for chaining

array getColumns()

Returns the list of internal columns

Return Value

array List of internal columns

JGrid deleteColumn( string $name)

Delete column by name

Parameters

string $name Name of the column to be deleted

Return Value

JGrid This object for chaining

JGrid 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

JGrid This object for chaining

JGrid addRow( array $options = array(), int $special = false)

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

Parameters

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

Return Value

JGrid This object for chaining

array getRowOptions()

Method to get the attributes of the currently active row

Return Value

array Associative array of attributes

JGrid setRowOptions( array $options)

Method to set the attributes of the currently active row

Parameters

array $options Associative array of attributes

Return Value

JGrid This object for chaining

int getActiveRow()

Get the currently active row ID

Return Value

int ID of the currently active row

JGrid setActiveRow( int $id)

Set the currently active row

Parameters

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

Return Value

JGrid This object for chaining

JGrid setRowCell( string $name, string $content, array $option = 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 $option 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

JGrid This object for chaining

array getRow( int $id = false)

Get all data for a row

Parameters

int $id ID of the row to return

Return Value

array Array of columns of a table row

array getRows( int $special = false)

Get the IDs of all rows in the table

Parameters

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

Return Value

array Array of IDs

JGrid deleteRow( int $id)

Delete a row from the object

Parameters

int $id ID of the row to be deleted

Return Value

JGrid This object for chaining

string toString()

Render the HTML table

Return Value

string The rendered HTML table