From 8e5627918e7f0c437df1a47af27545132a1c3cbc Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 20 Feb 2006 16:45:58 +0000 Subject: some more refactoring. --- .../Web/UI/WebControls/TEditCommandColumn.php | 35 +++++++++------------- 1 file changed, 14 insertions(+), 21 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 954ef8f7..abc372a0 100644 --- a/framework/Web/UI/WebControls/TEditCommandColumn.php +++ b/framework/Web/UI/WebControls/TEditCommandColumn.php @@ -154,43 +154,36 @@ class TEditCommandColumn extends TDataGridColumn { parent::initializeCell($cell,$columnIndex,$itemType); if($itemType==='Item' || $itemType==='AlternatingItem' || $itemType==='SelectedItem') - $this->addButtonToCell($cell,'Edit',$this->getEditText(),false,''); + $cell->getControls()->add($this->createButton('Edit',$this->getEditText(),false,'')); else if($itemType==='EditItem') { - $this->addButtonToCell($cell,'Update',$this->getUpdateText(),$this->getCausesValidation(),$this->getValidationGroup()); - $cell->getControls()->add(' '); - $this->addButtonToCell($cell,'Cancel',$this->getCancelText(),false,''); + $controls=$cell->getControls(); + $controls->add($this->createButton('Update',$this->getUpdateText(),$this->getCausesValidation(),$this->getValidationGroup())); + $controls->add(' '); + $controls->add($this->createButton('Cancel',$this->getCancelText(),false,'')); } } /** - * Creates a button and adds it to the cell. - * @param TTableCell the cell that the button is created within + * Creates a button and initializes its properties. + * The button type is determined by {@link getButtonType ButtonType}. * @param string command name associated with the button * @param string button caption * @param boolean whether the button should cause validation * @param string the validation group that the button belongs to + * @return mixed the newly created button. */ - protected function addButtonToCell($cell,$commandName,$text,$causesValidation,$validationGroup) + protected function createButton($commandName,$text,$causesValidation,$validationGroup) { - $button=$this->createButton(); + if($this->getButtonType()==='LinkButton') + $button=Prado::createComponent('System.Web.UI.WebControls.TLinkButton'); + else + $button=Prado::createComponent('System.Web.UI.WebControls.TButton'); $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'); + return $button; } } -- cgit v1.2.3