cvs: pear /Structures_DataGrid/DataGrid/Renderer HTMLTable.php
| From: | Andrew Nagy | Date: | Fri, 25 Jun 2004 15:48:18 +0000 |
| Subject: | cvs: pear /Structures_DataGrid/DataGrid/Renderer HTMLTable.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-21122@lists.php.net to get a copy of this message | ||
asnagy Fri Jun 25 11:48:18 2004 EDT
Modified files:
/pear/Structures_DataGrid/DataGrid/Renderer HTMLTable.php
Log:
Added new method allowEmptyRows which controls the allowEmptyRows and emptyRowAttributes variables
http://cvs.php.net/diff.php/pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php?r1=1.10&r2=1.11&ty=u
Index: pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php
diff -u pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.10
pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.11
--- pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.10 Fri Jun 25 10:38:35 2004
+++ pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php Fri Jun 25 11:48:18 2004
@@ -16,7 +16,7 @@
// | Author: Andrew Nagy <asnagy@webitecture.org> |
// +----------------------------------------------------------------------+
//
-// $Id: HTMLTable.php,v 1.10 2004/06/25 14:38:35 asnagy Exp $
+// $Id: HTMLTable.php,v 1.11 2004/06/25 15:48:18 asnagy Exp $
require_once 'HTML/Table.php';
require_once 'Pager/Pager.php';
@@ -24,7 +24,7 @@
/**
* Structures_DataGrid_Renderer_HTMLTable Class
*
- * @version $Revision: 1.10 $
+ * @version $Revision: 1.11 $
* @author Andrew S. Nagy <asnagy@webitecture.org>
* @access public
* @package Structures_DataGrid
@@ -148,6 +148,32 @@
$this->table->setAutoFill($value);
}
+ /**
+ * In order for the DataGrid to render "Empty Rows" to allow for
+ * uniformity across pages with varying results, set this option
+ * to true. An example of this would be when you have 11 results
+ * and have the DataGrid show 10 records per page. The last page
+ * will only show one row in the table, unless this option is
+ * turned on in which it will render 10 rows, 9 of which will be
+ * empty.
+ *
+ * @access public
+ * @param bool $value A boolean value to determine
+ * whether or not to display the
+ * empty rows.
+ * @param array $attributes The empty row attributes
+ * defined in an array.
+ */
+ function allowEmptyRows($value, $attributes = array())
+ {
+ if ($value) {
+ $this->allowEmptyRows = true;
+ } else {
+ $this->allowEmptyRows = false;
+ }
+
+ $this->emptyRowAttributes = $attributes;
+ }
/**
* Generates the HTML for the DataGrid
@@ -155,6 +181,7 @@
* @access public
* @return string The HTML of the DataGrid
*/
+
function render(&$dg)
{
$this->_dg = &$dg;
@@ -170,7 +197,8 @@
// Define Alternating Row attributes
$this->_table->altRowAttributes(1,
$this->evenRowAttributes,
- $this->oddRowAttributes);
+ $this->oddRowAttributes,
+ TRUE);
// Print the table
return $this->_table->toHTML();
@@ -302,9 +330,10 @@
// Determine if empty row should be printed
if ($this->allowEmptyRows) {
$rowCnt++;
- $this->_table->setRowAttributes($rowCnt,
- $this->emptyRowAttributes, false);
- $this->_table->setCellContents($rowCnt, 0, ' ');
+ for ($j=0; $j<count($this->_dg->columnSet); $j++) {
+ $this->_table->setCellAttributes($rowCnt, $j,
$this->emptyRowAttributes);
+ $this->_table->setCellContents($rowCnt, $j,
' ');
+ }
}
}
}