From 6228d146f105f9edc88d3341dd68944e9bf8b882 Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 24 Feb 2006 15:22:58 +0000 Subject: Fixed #69. --- framework/Web/UI/WebControls/TDataGrid.php | 34 +++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php index 4741b56e..c6d27b7e 100644 --- a/framework/Web/UI/WebControls/TDataGrid.php +++ b/framework/Web/UI/WebControls/TDataGrid.php @@ -184,7 +184,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer public function getColumns() { if(!$this->_columns) - $this->_columns=new TDataGridColumnCollection; + $this->_columns=new TDataGridColumnCollection($this); return $this->_columns; } @@ -194,7 +194,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer public function getAutoColumns() { if(!$this->_autoColumns) - $this->_autoColumns=new TDataGridColumnCollection; + $this->_autoColumns=new TDataGridColumnCollection($this); return $this->_autoColumns; } @@ -816,7 +816,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer $state=$this->getViewState('AutoColumns',array()); if(!empty($state)) { - $this->_autoColumns=new TDataGridColumnCollection; + $this->_autoColumns=new TDataGridColumnCollection($this); foreach($state as $st) { $column=new TBoundColumn; @@ -1221,7 +1221,6 @@ class TDataGrid extends TBaseDataList implements INamingContainer $column->setHeaderText($key); $column->setDataField($key); $column->setSortExpression($key); - $column->setOwner($this); $autoColumns->add($column); } else @@ -1229,7 +1228,6 @@ class TDataGrid extends TBaseDataList implements INamingContainer $column->setHeaderText('Item'); $column->setDataField($key); $column->setSortExpression('Item'); - $column->setOwner($this); $autoColumns->add($column); } } @@ -1756,6 +1754,29 @@ class TDataGridItemCollection extends TList */ class TDataGridColumnCollection extends TList { + /** + * the control that owns this collection. + * @var TControl + */ + private $_o; + + /** + * Constructor. + * @param TDataGrid the control that owns this collection. + */ + public function __construct(TDataGrid $owner) + { + $this->_o=$owner; + } + + /** + * @return TDataGrid the control that owns this collection. + */ + protected function getOwner() + { + return $this->_o; + } + /** * Inserts an item at the specified position. * This overrides the parent implementation by inserting only TDataGridColumn. @@ -1766,7 +1787,10 @@ class TDataGridColumnCollection extends TList public function insertAt($index,$item) { if($item instanceof TDataGridColumn) + { + $item->setOwner($this->_o); parent::insertAt($index,$item); + } else throw new TInvalidDataTypeException('datagridcolumncollection_datagridcolumn_required'); } -- cgit v1.2.3