summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY1
-rw-r--r--demos/quickstart/protected/pages/GettingStarted/NewFeatures.page3
-rw-r--r--framework/Web/UI/WebControls/TDataGrid.php68
-rw-r--r--framework/Web/UI/WebControls/TDataGridColumn.php32
-rw-r--r--framework/Web/UI/WebControls/THyperLink.php16
-rw-r--r--index.html3
6 files changed, 109 insertions, 14 deletions
diff --git a/HISTORY b/HISTORY
index d0b254b2..c6f7b3b5 100644
--- a/HISTORY
+++ b/HISTORY
@@ -9,6 +9,7 @@ BUG: Ticket#662 - Ensure TForm to properly encode the ampersand in action URL (Q
BUG: Ticket#666 - TActiveRecord::deleteAll() method always requires a criteria or null parameter (Qiang)
BUG: Ticket#670 - TDatePicker: Year Issue (Christophe)
BUG: Ticket#689 - TRangeValidator: Problem in clientscript when MaxValue=<%= 0 %> (Qiang)
+ENH: Ticket#370 - TDataGrid now supports grouping cells (Qiang)
ENH: Ticket#577 - Added image button support for TPager (Qiang)
ENH: Ticket#623 - TMemCache to support multiple servers (Carl)
ENH: Ticket#664 - Added support to styling thead, tbody, tfoot of TDataGrid (Qiang)
diff --git a/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page b/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page
index 6d5b89e4..be754e65 100644
--- a/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page
+++ b/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page
@@ -12,7 +12,8 @@ This page summarizes the main new features that are introduced in each PRADO rel
<li>Added a new control <a href="?page=Controls.Keyboard">TKeyboard</a> that displays a virtual keyboard for text input.</li>
<li>Added a new control <a href="?page=Controls.Captcha">TCaptcha</a> that displays a CAPTCHA to keep spammers from signing up for certain accounts online. A related validator <tt>TCaptchaValidator</tt> is also implemented.</li>
<li>Added a new control <a href="?page=Controls.Slider">TSlider</a> that displays a slider which can be used for numeric input.</li>
-<li>Added Oracle DB support to Active Record</li>
+<li>Added Oracle DB support to Active Record.</li>
+<li>Added support of TDataGrid to allow grouping consecutive cells with the same content.</li>
</ul>
<h2 id="8006">Version 3.1.0</h2>
diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php
index 547c769d..9803d511 100644
--- a/framework/Web/UI/WebControls/TDataGrid.php
+++ b/framework/Web/UI/WebControls/TDataGrid.php
@@ -186,6 +186,10 @@ class TDataGrid extends TBaseDataList implements INamingContainer
*/
private $_autoColumns=null;
/**
+ * @var TList all columns including both manually and automatically created columns
+ */
+ private $_allColumns=null;
+ /**
* @var TDataGridItemCollection datagrid item collection
*/
private $_items=null;
@@ -948,6 +952,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$columns=new TList($this->getColumns());
$columns->mergeWith($this->_autoColumns);
+ $this->_allColumns=$columns;
$items=$this->getItems();
@@ -1012,6 +1017,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
}
else
$columns=$this->getColumns();
+ $this->_allColumns=$columns;
$items=$this->getItems();
@@ -1067,6 +1073,66 @@ class TDataGrid extends TBaseDataList implements INamingContainer
}
/**
+ * Merges consecutive cells who have the same text.
+ * @since 3.1.1
+ */
+ private function groupCells()
+ {
+ if(($columns=$this->_allColumns)===null)
+ return;
+ $items=$this->getItems();
+ foreach($columns as $id=>$column)
+ {
+ if(!$column->getEnableCellGrouping())
+ continue;
+ $prevCell=null;
+ $prevCellText=null;
+ foreach($items as $item)
+ {
+ $itemType=$item->getItemType();
+ $cell=$item->getCells()->itemAt($id);
+ if(!$cell->getVisible())
+ continue;
+ if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::SelectedItem)
+ {
+ if(($cellText=$this->getCellText($cell))==='')
+ {
+ $prevCell=null;
+ $prevCellText=null;
+ continue;
+ }
+ if($prevCell===null || $prevCellText!==$cellText)
+ {
+ $prevCell=$cell;
+ $prevCellText=$cellText;
+ }
+ else
+ {
+ if(($rowSpan=$prevCell->getRowSpan())===0)
+ $rowSpan=1;
+ $prevCell->setRowSpan($rowSpan+1);
+ $cell->setVisible(false);
+ }
+ }
+ }
+ }
+ }
+
+ private function getCellText($cell)
+ {
+ if(($data=$cell->getText())==='' && $cell->getHasControls())
+ {
+ $controls=$cell->getControls();
+ foreach($controls as $control)
+ {
+ if($control instanceof IDataRenderer)
+ return $control->getData();
+ }
+ }
+ return $data;
+ }
+
+ /**
* Creates a datagrid item instance based on the item type and index.
* @param integer zero-based item index
* @param TListItemType item type
@@ -1089,7 +1155,6 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$this->getControls()->add($item);
$item->dataBind();
$this->onItemDataBound($param);
- $item->setDataItem(null);
}
else
{
@@ -1485,6 +1550,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
{
if($this->getHasControls())
{
+ $this->groupCells();
if($this->_useEmptyTemplate)
{
$control=new TWebControl;
diff --git a/framework/Web/UI/WebControls/TDataGridColumn.php b/framework/Web/UI/WebControls/TDataGridColumn.php
index 161f24eb..73c374b0 100644
--- a/framework/Web/UI/WebControls/TDataGridColumn.php
+++ b/framework/Web/UI/WebControls/TDataGridColumn.php
@@ -27,15 +27,23 @@ Prado::using('System.Web.UI.WebControls.TDataGrid');
* The {@link getItemStyle ItemStyle} is applied to cells that belong to
* non-header and -footer datagrid items.
*
+ * When the datagrid enables sorting, if the {@link setSortExpression SortExpression}
+ * is not empty, the header cell will display a button (linkbutton or imagebutton)
+ * that will bubble the sort command event to the datagrid.
+ *
* Since v3.1.0, TDataGridColumn has introduced two new properties {@link setHeaderRenderer HeaderRenderer}
* and {@link setFooterRenderer FooterRenderer} which can be used to specify
* the layout of header and footer column cells.
* A renderer refers to a control class that is to be instantiated as a control.
* For more details, see {@link TRepeater} and {@link TDataList}.
*
- * When the datagrid enables sorting, if the {@link setSortExpression SortExpression}
- * is not empty, the header cell will display a button (linkbutton or imagebutton)
- * that will bubble the sort command event to the datagrid.
+ * Since v3.1.1, TDataGridColumn has introduced {@link setEnableCellGrouping EnableCellGrouping}.
+ * If a column has this property set true, consecutive cells having the same content in this
+ * column will be grouped into one cell.
+ * Note, there are some limitations to cell grouping. We determine the cell content according to
+ * the cell's {@link TTableCell::getText Text} property. If the text is empty and the cell has
+ * some child controls, we will pick up the first control who implements {@link IDataRenderer}
+ * and obtain its {@link IDataRenderer::getData Data} property.
*
* The following datagrid column types are provided by the framework currently,
* - {@link TBoundColumn}, associated with a specific field in datasource and displays the corresponding data.
@@ -237,6 +245,24 @@ abstract class TDataGridColumn extends TApplicationComponent
}
/**
+ * @return boolean whether cells having the same content should be grouped together. Defaults to false.
+ * @since 3.1.1
+ */
+ public function getEnableCellGrouping()
+ {
+ return $this->getViewState('EnableCellGrouping',false);
+ }
+
+ /**
+ * @param boolean whether cells having the same content should be grouped together.
+ * @since 3.1.1
+ */
+ public function setEnableCellGrouping($value)
+ {
+ $this->setViewState('EnableCellGrouping',TPropertyValue::ensureBoolean($value),false);
+ }
+
+ /**
* @return boolean whether the column is visible. Defaults to true.
*/
public function getVisible($checkParents=true)
diff --git a/framework/Web/UI/WebControls/THyperLink.php b/framework/Web/UI/WebControls/THyperLink.php
index 13a9ab41..0287029f 100644
--- a/framework/Web/UI/WebControls/THyperLink.php
+++ b/framework/Web/UI/WebControls/THyperLink.php
@@ -145,27 +145,27 @@ class THyperLink extends TWebControl implements IDataRenderer
/**
* Returns the URL to link to when the THyperLink component is clicked.
* This method is required by {@link IDataRenderer}.
- * It is the same as {@link getNavigateUrl()}.
- * @return string the URL to link to when the THyperLink component is clicked
- * @see getNavigateUrl
+ * It is the same as {@link getText()}.
+ * @return string the text caption
+ * @see getText
* @since 3.1.0
*/
public function getData()
{
- return $this->getNavigateUrl();
+ return $this->getText();
}
/**
* Sets the URL to link to when the THyperLink component is clicked.
* This method is required by {@link IDataRenderer}.
- * It is the same as {@link setNavigateUrl()}.
- * @param string the URL to link to when the THyperLink component is clicked
- * @see setNavigateUrl
+ * It is the same as {@link setText()}.
+ * @param string the text caption to be set
+ * @see setText
* @since 3.1.0
*/
public function setData($value)
{
- $this->setNavigateUrl($value);
+ $this->setText($value);
}
/**
diff --git a/index.html b/index.html
index c7bc2e61..5f83ce3d 100644
--- a/index.html
+++ b/index.html
@@ -95,8 +95,9 @@ PRADO component tags when you use it to edit PRADO templates.
<h3>Translations</h3>
<ul>
-<li>Indonesian: <a href="mailto:zaenalm@gmail.com">Zaenal Mutaqin</a></li>
+<li>Indonesian: Zaenal Mutaqin</li>
<li>French: Eric Marchetti</li>
+<li>Japanese: Yoshinari Ueyama, Shinya Kawamura, Tsuchimoto Hiroki</li>
</ul>
<h3>Prado v2 Maintenance Team</h3>