From ee43ef11c96e8d3f7065243ace88d8abfef0147c Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 20 Feb 2006 16:36:47 +0000 Subject: Refactored TEditCommandColumn to make it easier for being extended. --- framework/Web/UI/WebControls/TEditCommandColumn.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'framework/Web/UI/WebControls/TEditCommandColumn.php') diff --git a/framework/Web/UI/WebControls/TEditCommandColumn.php b/framework/Web/UI/WebControls/TEditCommandColumn.php index 6cb93a39..954ef8f7 100644 --- a/framework/Web/UI/WebControls/TEditCommandColumn.php +++ b/framework/Web/UI/WebControls/TEditCommandColumn.php @@ -153,7 +153,6 @@ class TEditCommandColumn extends TDataGridColumn public function initializeCell($cell,$columnIndex,$itemType) { parent::initializeCell($cell,$columnIndex,$itemType); - $buttonType=$this->getButtonType()=='LinkButton'?'TLinkButton':'TButton'; if($itemType==='Item' || $itemType==='AlternatingItem' || $itemType==='SelectedItem') $this->addButtonToCell($cell,'Edit',$this->getEditText(),false,''); else if($itemType==='EditItem') @@ -174,16 +173,25 @@ class TEditCommandColumn extends TDataGridColumn */ protected function addButtonToCell($cell,$commandName,$text,$causesValidation,$validationGroup) { - if($this->getButtonType()==='LinkButton') - $button=Prado::createComponent('System.Web.UI.WebControls.TLinkButton'); - else - $button=Prado::createComponent('System.Web.UI.WebControls.TButton'); + $button=$this->createButton(); $button->setText($text); $button->setCommandName($commandName); $button->setCausesValidation($causesValidation); $button->setValidationGroup($validationGroup); $cell->getControls()->add($button); } + + /** + * Creates a button by {@link getButtonType ButtonType}. + * @return mixed the newly created button. + */ + protected function createButton() + { + if($this->getButtonType()==='LinkButton') + return Prado::createComponent('System.Web.UI.WebControls.TLinkButton'); + else + return Prado::createComponent('System.Web.UI.WebControls.TButton'); + } } ?> \ No newline at end of file -- cgit v1.2.3