summaryrefslogtreecommitdiff
path: root/framework/Web/UI
diff options
context:
space:
mode:
authorctrlaltca@gmail.com <>2011-06-16 11:42:22 +0000
committerctrlaltca@gmail.com <>2011-06-16 11:42:22 +0000
commit4f8b5fd3b1e9436c1c2d904ecdb881972698dad6 (patch)
tree12b26b533ecfc8bed97cb5a8d5128386fb456050 /framework/Web/UI
parent3b81618f6f8c9949546579ea0168a30195a51685 (diff)
Merged a bit TPager's view style with TDataGridPager's one adding first/last buttons to TDataGridPagerStyle
Diffstat (limited to 'framework/Web/UI')
-rw-r--r--framework/Web/UI/WebControls/TDataGrid.php44
-rw-r--r--framework/Web/UI/WebControls/TDataGridPagerStyle.php38
2 files changed, 80 insertions, 2 deletions
diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php
index d2147c49..4c7fca97 100644
--- a/framework/Web/UI/WebControls/TDataGrid.php
+++ b/framework/Web/UI/WebControls/TDataGrid.php
@@ -176,6 +176,8 @@ class TDataGrid extends TBaseDataList implements INamingContainer
const CMD_PAGE='Page';
const CMD_PAGE_NEXT='Next';
const CMD_PAGE_PREV='Previous';
+ const CMD_PAGE_FIRST='First';
+ const CMD_PAGE_LAST='Last';
/**
* @var TDataGridColumnCollection manually created column collection
@@ -736,6 +738,10 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$pageIndex=$this->getCurrentPageIndex()+1;
else if(strcasecmp($p,self::CMD_PAGE_PREV)===0)
$pageIndex=$this->getCurrentPageIndex()-1;
+ else if(strcasecmp($p,self::CMD_PAGE_FIRST)===0)
+ $pageIndex=0;
+ else if(strcasecmp($p,self::CMD_PAGE_LAST)===0)
+ $pageIndex=$this->getPageCount()-1;
else
$pageIndex=TPropertyValue::ensureInteger($p)-1;
$this->onPageIndexChanged(new TDataGridPageChangedEventParameter($sender,$pageIndex));
@@ -1264,11 +1270,25 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$currentPageIndex=$this->getCurrentPageIndex();
if($currentPageIndex===0)
{
+ if(($text=$style->getFirstPageText())!=='')
+ {
+ $label=$this->createPagerButton($buttonType,false,$text,'','');
+ $controls->add($label);
+ $controls->add("\n");
+ }
+
$label=$this->createPagerButton($buttonType,false,$style->getPrevPageText(),'','');
$controls->add($label);
}
else
{
+ if(($text=$style->getFirstPageText())!=='')
+ {
+ $button=$this->createPagerButton($buttonType,true,$text,self::CMD_PAGE,self::CMD_PAGE_FIRST);
+ $controls->add($button);
+ $controls->add("\n");
+ }
+
$button=$this->createPagerButton($buttonType,true,$style->getPrevPageText(),self::CMD_PAGE,self::CMD_PAGE_PREV);
$controls->add($button);
}
@@ -1277,11 +1297,23 @@ class TDataGrid extends TBaseDataList implements INamingContainer
{
$label=$this->createPagerButton($buttonType,false,$style->getNextPageText(),'','');
$controls->add($label);
+ if(($text=$style->getLastPageText())!=='')
+ {
+ $controls->add("\n");
+ $label=$this->createPagerButton($buttonType,false,$text,'','');
+ $controls->add($label);
+ }
}
else
{
$button=$this->createPagerButton($buttonType,true,$style->getNextPageText(),self::CMD_PAGE,self::CMD_PAGE_NEXT);
$controls->add($button);
+ if(($text=$style->getLastPageText())!=='')
+ {
+ $controls->add("\n");
+ $button=$this->createPagerButton($buttonType,true,$text,self::CMD_PAGE,self::CMD_PAGE_LAST);
+ $controls->add($button);
+ }
}
}
@@ -1314,6 +1346,12 @@ class TDataGrid extends TBaseDataList implements INamingContainer
if($startPageIndex>1)
{
+ if(($text=$style->getFirstPageText())!=='')
+ {
+ $button=$this->createPagerButton($buttonType,true,$text,self::CMD_PAGE,self::CMD_PAGE_FIRST);
+ $controls->add($button);
+ $controls->add("\n");
+ }
$prevPageIndex=$startPageIndex-1;
$button=$this->createPagerButton($buttonType,true,$style->getPrevPageText(),self::CMD_PAGE,"$prevPageIndex");
$controls->add($button);
@@ -1342,6 +1380,12 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$nextPageIndex=$endPageIndex+1;
$button=$this->createPagerButton($buttonType,true,$style->getNextPageText(),self::CMD_PAGE,"$nextPageIndex");
$controls->add($button);
+ if(($text=$style->getLastPageText())!=='')
+ {
+ $controls->add("\n");
+ $button=$this->createPagerButton($buttonType,true,$text,self::CMD_PAGE,self::CMD_PAGE_LAST);
+ $controls->add($button);
+ }
}
}
diff --git a/framework/Web/UI/WebControls/TDataGridPagerStyle.php b/framework/Web/UI/WebControls/TDataGridPagerStyle.php
index e29b9dc9..6d31e72d 100644
--- a/framework/Web/UI/WebControls/TDataGridPagerStyle.php
+++ b/framework/Web/UI/WebControls/TDataGridPagerStyle.php
@@ -4,7 +4,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.WebControls
@@ -27,6 +27,8 @@ class TDataGridPagerStyle extends TPanelStyle
private $_mode=null;
private $_nextText=null;
private $_prevText=null;
+ private $_firstText=null;
+ private $_lastText=null;
private $_buttonCount=null;
private $_position=null;
private $_visible=null;
@@ -89,7 +91,7 @@ class TDataGridPagerStyle extends TPanelStyle
}
/**
- * @param string text for the next page button.
+ * @param string text for the previous page button.
*/
public function setPrevPageText($value)
{
@@ -97,6 +99,38 @@ class TDataGridPagerStyle extends TPanelStyle
}
/**
+ * @return string text for the first page button. Defaults to '<<'.
+ */
+ public function getFirstPageText()
+ {
+ return $this->_firstText===null?'<<':$this->_firstText;
+ }
+
+ /**
+ * @param string text for the first page button.
+ */
+ public function setFirstPageText($value)
+ {
+ $this->_firstText=$value;
+ }
+
+ /**
+ * @return string text for the last page button. Defaults to '>>'.
+ */
+ public function getLastPageText()
+ {
+ return $this->_lastText===null?'>>':$this->_lastText;
+ }
+
+ /**
+ * @param string text for the last page button.
+ */
+ public function setLastPageText($value)
+ {
+ $this->_lastText=$value;
+ }
+
+ /**
* @return integer maximum number of pager buttons to be displayed. Defaults to 10.
*/
public function getPageButtonCount()