From 7b5b0e2d4000fadabcdad894538e42c23ebb9ecd Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Tue, 2 Mar 2010 22:48:53 -0600 Subject: expanded abilities of Table library --- user_guide/libraries/table.html | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'user_guide/libraries') diff --git a/user_guide/libraries/table.html b/user_guide/libraries/table.html index 1c67e4b8e..b233dbf85 100644 --- a/user_guide/libraries/table.html +++ b/user_guide/libraries/table.html @@ -2,17 +2,16 @@ - -HTML Table Class : CodeIgniter User Guide +CodeIgniter User Guide : HTML Table Class - - + - - - - + + + + + @@ -24,7 +23,7 @@ - +
@@ -199,6 +198,14 @@ $this->table->set_template($tmpl); $this->table->add_row('Blue', 'Red', 'Green');$this->table->add_row(array('Blue', 'Red', 'Green')); +

If you would like to set an individual cell's tag attributes, you can use an associative array for that cell. The associative key 'data' defines the cell's data. Any other key => val pairs are added as key='val' attributes to the tag:

+ +$cell = array('data' => 'Blue', 'class' => 'highlight', 'colspan' => 2);
+$this->table->add_row($cell, 'Red', 'Green');
+
+// generates
+// <td class='highlight' colspan='2'>Blue</td><td>Red</td><td>Green</td> +

$this->table->make_columns()

@@ -274,6 +281,22 @@ $this->table->add_row('John', 'Saturday', 'Overnight');
echo $this->table->generate(); +

$this->table->function

+ +

Allows you to specify a native PHP function or a valid function array object to be applied to all cell data.

+ +$this->load->library('table');
+
+$this->table->set_heading('Name', 'Color', 'Size');
+$this->table->add_row('Fred', '<strong>Blue</strong>', 'Small');
+
+$this->table->function = 'htmlspecialchars';
+echo $this->table->generate();
+
+ +

In the above example, all cell data would be ran through PHP's htmlspecialchars() function, resulting in:

+ +<td>Fred</td><td>&lt;strong&gt;Blue&lt;/strong&gt;</td><td>Small</td> -- cgit v1.2.3-24-g4f1b