From 4c0769c422967b50204ad665a5e3705cddc0bcd1 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 14 Mar 2006 22:36:55 +0000 Subject: Used constants to represent button command strings. --- framework/Web/UI/WebControls/TDataGrid.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'framework/Web') diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php index e95dd504..c6e46c72 100644 --- a/framework/Web/UI/WebControls/TDataGrid.php +++ b/framework/Web/UI/WebControls/TDataGrid.php @@ -134,6 +134,16 @@ Prado::using('System.Web.UI.WebControls.TTable'); */ class TDataGrid extends TBaseDataList implements INamingContainer { + const CMD_SELECT='Select'; + const CMD_EDIT='Edit'; + const CMD_UPDATE='Update'; + const CMD_DELETE='Delete'; + const CMD_CANCEL='Cancel'; + const CMD_SORT='Sort'; + const CMD_PAGE='Page'; + const CMD_PAGE_NEXT='Next'; + const CMD_PAGE_PREV='Prev'; + /** * @var TDataGridColumnCollection manually created column collection */ @@ -625,43 +635,43 @@ class TDataGrid extends TBaseDataList implements INamingContainer { $this->onItemCommand($param); $command=$param->getCommandName(); - if(strcasecmp($command,'select')===0) + if(strcasecmp($command,self::CMD_SELECT)===0) { $this->setSelectedItemIndex($param->getItem()->getItemIndex()); $this->onSelectedIndexChanged(null); return true; } - else if(strcasecmp($command,'edit')===0) + else if(strcasecmp($command,self::CMD_EDIT)===0) { $this->onEditCommand($param); return true; } - else if(strcasecmp($command,'delete')===0) + else if(strcasecmp($command,self::CMD_DELETE)===0) { $this->onDeleteCommand($param); return true; } - else if(strcasecmp($command,'update')===0) + else if(strcasecmp($command,self::CMD_UPDATE)===0) { $this->onUpdateCommand($param); return true; } - else if(strcasecmp($command,'cancel')===0) + else if(strcasecmp($command,self::CMD_CANCEL)===0) { $this->onCancelCommand($param); return true; } - else if(strcasecmp($command,'sort')===0) + else if(strcasecmp($command,self::CMD_SORT)===0) { $this->onSortCommand(new TDataGridSortCommandEventParameter($sender,$param)); return true; } - else if(strcasecmp($command,'page')===0) + else if(strcasecmp($command,self::CMD_PAGE)===0) { $p=$param->getCommandParameter(); - if(strcasecmp($p,'next')===0) + if(strcasecmp($p,self::CMD_PAGE_NEXT)===0) $pageIndex=$this->getCurrentPageIndex()+1; - else if(strcasecmp($p,'prev')===0) + else if(strcasecmp($p,self::CMD_PAGE_PREV)===0) $pageIndex=$this->getCurrentPageIndex()-1; else $pageIndex=TPropertyValue::ensureInteger($p)-1; -- cgit v1.2.3