From 54900d0145dfda07bde40dc6e1f0b31935b55444 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 17 Jan 2006 23:58:54 +0000 Subject: --- framework/Web/UI/WebControls/TTable.php | 72 ++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) (limited to 'framework/Web/UI/WebControls/TTable.php') diff --git a/framework/Web/UI/WebControls/TTable.php b/framework/Web/UI/WebControls/TTable.php index 13cbd0b1..3ca3d51d 100644 --- a/framework/Web/UI/WebControls/TTable.php +++ b/framework/Web/UI/WebControls/TTable.php @@ -124,7 +124,7 @@ class TTable extends TWebControl public function getRows() { if(!$this->_rows) - $this->_rows=new TTableRowCollection(); + $this->_rows=new TTableRowCollection($this); return $this->_rows; } @@ -352,7 +352,7 @@ class TTableRow extends TWebControl public function getCells() { if(!$this->_cells) - $this->_cells=new TTableCellCollection(); + $this->_cells=new TTableCellCollection($this); return $this->_cells; } @@ -697,6 +697,20 @@ class TTableHeaderCell extends TTableCell */ class TTableRowCollection extends TList { + /** + * @var mixed row collection owner + */ + private $_owner=null; + + /** + * Constructor. + * @param mixed row collection owner + */ + public function __construct($owner=null) + { + $this->_owner=$owner; + } + /** * Only string or instance of TControl can be added into collection. * @param mixed the item to be added @@ -705,6 +719,26 @@ class TTableRowCollection extends TList { return ($item instanceof TTableRow); } + + /** + * Overrides the parent implementation with customized processing of the newly added item. + * @param mixed the newly added item + */ + protected function addedItem($item) + { + if($this->_owner) + $this->_owner->getControls()->add($item); + } + + /** + * Overrides the parent implementation with customized processing of the removed item. + * @param mixed the removed item + */ + protected function removedItem($item) + { + if($this->_owner) + $this->_owner->getControls()->remove($item); + } } @@ -720,6 +754,20 @@ class TTableRowCollection extends TList */ class TTableCellCollection extends TList { + /** + * @var mixed cell collection owner + */ + private $_owner=null; + + /** + * Constructor. + * @param mixed cell collection owner + */ + public function __construct($owner=null) + { + $this->_owner=$owner; + } + /** * Only string or instance of TTableCell can be added into collection. * @param mixed the item to be added @@ -728,5 +776,25 @@ class TTableCellCollection extends TList { return ($item instanceof TTableCell); } + + /** + * Overrides the parent implementation with customized processing of the newly added item. + * @param mixed the newly added item + */ + protected function addedItem($item) + { + if($this->_owner) + $this->_owner->getControls()->add($item); + } + + /** + * Overrides the parent implementation with customized processing of the removed item. + * @param mixed the removed item + */ + protected function removedItem($item) + { + if($this->_owner) + $this->_owner->getControls()->remove($item); + } } ?> \ No newline at end of file -- cgit v1.2.3