diff options
Diffstat (limited to 'framework')
-rw-r--r-- | framework/Web/UI/WebControls/TDataGrid.php | 93 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TRepeatInfo.php | 8 |
2 files changed, 95 insertions, 6 deletions
diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php index 55b12ebc..6ff6faba 100644 --- a/framework/Web/UI/WebControls/TDataGrid.php +++ b/framework/Web/UI/WebControls/TDataGrid.php @@ -357,6 +357,39 @@ class TDataGrid extends TBaseDataList implements INamingContainer }
/**
+ * @return string caption for the datagrid
+ */
+ public function getCaption()
+ {
+ return $this->getViewState('Caption','');
+ }
+
+ /**
+ * @param string caption for the datagrid
+ */
+ public function setCaption($value)
+ {
+ $this->setViewState('Caption',$value,'');
+ }
+
+ /**
+ * @return string datagrid caption alignment. Defaults to 'NotSet'.
+ */
+ public function getCaptionAlign()
+ {
+ return $this->getViewState('CaptionAlign','NotSet');
+ }
+
+ /**
+ * @param string datagrid caption alignment. Valid values include
+ * 'NotSet','Top','Bottom','Left','Right'.
+ */
+ public function setCaptionAlign($value)
+ {
+ $this->setViewState('CaptionAlign',TPropertyValue::ensureEnum($value,'NotSet','Top','Bottom','Left','Right'),'NotSet');
+ }
+
+ /**
* @return TDataGridItem the header item
*/
public function getHeader()
@@ -1444,6 +1477,23 @@ class TDataGrid extends TBaseDataList implements INamingContainer }
/**
+ * Renders the openning tag for the datagrid control which will render table caption if present.
+ * @param THtmlWriter the writer used for the rendering purpose
+ */
+ public function renderBeginTag($writer)
+ {
+ parent::renderBeginTag($writer);
+ if(($caption=$this->getCaption())!=='')
+ {
+ if(($align=$this->getCaptionAlign())!=='NotSet')
+ $writer->addAttribute('align',strtolower($align));
+ $writer->renderBeginTag('caption');
+ $writer->write($caption);
+ $writer->renderEndTag();
+ }
+ }
+
+ /**
* Renders the datagrid.
* @param THtmlWriter writer for the rendering purpose
*/
@@ -1457,12 +1507,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer $this->_topPager->renderControl($writer);
$writer->writeLine();
}
- $this->renderBeginTag($writer);
- $this->_header->renderControl($writer);
- foreach($this->getItems() as $item)
- $item->renderControl($writer);
- $this->_footer->renderControl($writer);
- $this->renderEndTag($writer);
+ $this->renderTable($writer);
if($this->_bottomPager)
{
$writer->writeLine();
@@ -1470,6 +1515,38 @@ class TDataGrid extends TBaseDataList implements INamingContainer }
}
}
+
+ /**
+ * Renders the tabular data.
+ * @param THtmlWriter writer
+ */
+ protected function renderTable($writer)
+ {
+ $this->renderBeginTag($writer);
+ if($this->_header->getVisible())
+ {
+ $writer->writeLine();
+ $writer->renderBeginTag('thead');
+ $this->_header->render($writer);
+ $writer->renderEndTag();
+ }
+ $writer->writeLine();
+ $writer->renderBeginTag('tbody');
+ foreach($this->getItems() as $item)
+ $item->renderControl($writer);
+ $writer->renderEndTag();
+
+ if($this->_footer->getVisible())
+ {
+ $writer->writeLine();
+ $writer->renderBeginTag('tfoot');
+ $this->_footer->render($writer);
+ $writer->renderEndTag();
+ }
+
+ $writer->writeLine();
+ $this->renderEndTag($writer);
+ }
}
/**
@@ -1758,6 +1835,10 @@ class TDataGridItem extends TTableRow implements INamingContainer $this->_itemIndex=$itemIndex;
$this->_dataSourceIndex=$dataSourceIndex;
$this->setItemType($itemType);
+ if($itemType===TDataGrid::IT_HEADER)
+ $this->setTableSection('Header');
+ else if($itemType===TDataGrid::IT_FOOTER)
+ $this->setTableSection('Footer');
}
/**
diff --git a/framework/Web/UI/WebControls/TRepeatInfo.php b/framework/Web/UI/WebControls/TRepeatInfo.php index 10c49691..81b82c33 100644 --- a/framework/Web/UI/WebControls/TRepeatInfo.php +++ b/framework/Web/UI/WebControls/TRepeatInfo.php @@ -261,6 +261,7 @@ class TRepeatInfo extends TComponent // render items
if($tableLayout)
{
+ $writer->renderBeginTag('tbody');
$column=0;
for($i=0;$i<$itemCount;++$i)
{
@@ -297,6 +298,7 @@ class TRepeatInfo extends TComponent $column=0;
}
}
+ $writer->renderEndTag();
}
else
{
@@ -353,6 +355,7 @@ class TRepeatInfo extends TComponent if($tableLayout)
{
+ $writer->renderBeginTag('tbody');
$renderedItems=0;
for($row=0;$row<$rows;++$row)
{
@@ -407,6 +410,7 @@ class TRepeatInfo extends TComponent $writer->renderEndTag();
$writer->writeLine();
}
+ $writer->renderEndTag();
}
else
{
@@ -461,6 +465,7 @@ class TRepeatInfo extends TComponent {
if($tableLayout)
{
+ $writer->renderBeginTag('thead');
$writer->renderBeginTag('tr');
if($columns>1)
$writer->addAttribute('colspan',"$columns");
@@ -471,6 +476,7 @@ class TRepeatInfo extends TComponent $user->renderItem($writer,$this,'Header',-1);
$writer->renderEndTag();
$writer->renderEndTag();
+ $writer->renderEndTag();
}
else
{
@@ -492,6 +498,7 @@ class TRepeatInfo extends TComponent {
if($tableLayout)
{
+ $writer->renderBeginTag('tfoot');
$writer->renderBeginTag('tr');
if($columns>1)
$writer->addAttribute('colspan',"$columns");
@@ -501,6 +508,7 @@ class TRepeatInfo extends TComponent $user->renderItem($writer,$this,'Footer',-1);
$writer->renderEndTag();
$writer->renderEndTag();
+ $writer->renderEndTag();
}
else
$user->renderItem($writer,$this,'Footer',-1);
|