Skip to content

CI_Table

Mathieu Nayrolles edited this page Jan 20, 2016 · 1 revision

CI_Table

HTML Table Generating Class

Lets you create tables manually or from database result objects, or arrays.

  • Class name: CI_Table
  • Namespace:

Properties

$rows

public array $rows = array()

Data for table rows

  • Visibility: public

$heading

public array $heading = array()

Data for table heading

  • Visibility: public

$auto_heading

public boolean $auto_heading = TRUE

Whether or not to automatically create the table header

  • Visibility: public

$caption

public string $caption = NULL

Table caption

  • Visibility: public

$template

public array $template = NULL

Table layout template

  • Visibility: public

$newline

public string $newline = "\n"

Newline setting

  • Visibility: public

$empty_cells

public string $empty_cells = ''

Contents of empty cells

  • Visibility: public

$function

public \function $function = NULL

Callback for custom table layout

  • Visibility: public

Methods

__construct

void CI_Table::__construct(array $config)

Set the template from the table config file if it exists

  • Visibility: public

Arguments

  • $config array - <p>(default: array())</p>

set_template

boolean CI_Table::set_template(array $template)

Set the template

  • Visibility: public

Arguments

  • $template array

set_heading

\CI_Table CI_Table::set_heading($args)

Set the table heading

Can be passed as an array or discreet params

  • Visibility: public

Arguments

  • $args mixed

make_columns

array CI_Table::make_columns(array $array, integer $col_limit)

Set columns. Takes a one-dimensional array as input and creates a multi-dimensional array with a depth equal to the number of columns. This allows a single array with many elements to be displayed in a table that has a fixed column count.

  • Visibility: public

Arguments

  • $array array
  • $col_limit integer

set_empty

\CI_Table CI_Table::set_empty(mixed $value)

Set "empty" cells

Can be passed as an array or discreet params

  • Visibility: public

Arguments

  • $value mixed

add_row

\CI_Table CI_Table::add_row($args)

Add a table row

Can be passed as an array or discreet params

  • Visibility: public

Arguments

  • $args mixed

_prep_args

array CI_Table::_prep_args($args)

Prep Args

Ensures a standard associative array format for all cell data

  • Visibility: protected

Arguments

  • $args mixed

set_caption

\CI_Table CI_Table::set_caption(string $caption)

Add a table caption

  • Visibility: public

Arguments

  • $caption string

generate

string CI_Table::generate(mixed $table_data)

Generate the table

  • Visibility: public

Arguments

  • $table_data mixed

clear

\CI_Table CI_Table::clear()

Clears the table arrays. Useful if multiple tables are being generated

  • Visibility: public

_set_from_db_result

void CI_Table::_set_from_db_result($object)

Set table data from a database result object

  • Visibility: protected

Arguments

  • $object mixed

_set_from_array

void CI_Table::_set_from_array(array $data)

Set table data from an array

  • Visibility: protected

Arguments

  • $data array

_compile_template

void CI_Table::_compile_template()

Compile Template

  • Visibility: protected

_default_template

array CI_Table::_default_template()

Default Template

  • Visibility: protected
Clone this wiki locally