summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/Web/UI/ActiveControls/TActiveDataGrid.php64
-rw-r--r--framework/Web/UI/WebControls/TDataGrid.php35
2 files changed, 81 insertions, 18 deletions
diff --git a/framework/Web/UI/ActiveControls/TActiveDataGrid.php b/framework/Web/UI/ActiveControls/TActiveDataGrid.php
index c4ad9640..02fc68e4 100644
--- a/framework/Web/UI/ActiveControls/TActiveDataGrid.php
+++ b/framework/Web/UI/ActiveControls/TActiveDataGrid.php
@@ -106,6 +106,7 @@ class TActiveDataGrid extends TDataGrid implements IActiveControl, ISurroundable
* If it is enabled (clickable), its command name and parameter will also be set.
* It overrides the datagrid's original method to create active controls instead, thus
* the pager will do callbacks instead of the regular postbacks.
+ * @param mixed the container pager instance of TActiveDatagridPager
* @param string button type, either LinkButton or PushButton
* @param boolean whether the button should be enabled
* @param string caption of the button
@@ -113,7 +114,7 @@ class TActiveDataGrid extends TDataGrid implements IActiveControl, ISurroundable
* @param string CommandParameter corresponding to the OnCommand event of the button
* @return mixed the button instance
*/
- protected function createPagerButton($buttonType,$enabled,$text,$commandName,$commandParameter) {
+ protected function createPagerButton($pager,$buttonType,$enabled,$text,$commandName,$commandParameter) {
if($buttonType===TDataGridPagerButtonType::LinkButton) {
if($enabled)
$button=new TActiveLinkButton;
@@ -132,9 +133,21 @@ class TActiveDataGrid extends TDataGrid implements IActiveControl, ISurroundable
$button->setCommandName($commandName);
$button->setCommandParameter($commandParameter);
$button->setCausesValidation(false);
+ $button->getAdapter()->getBaseActiveControl()->setClientSide(
+ $pager->getClientSide()
+ );
return $button;
}
+ protected function createPager()
+ {
+ $pager=new TActiveDataGridPager($this);
+ $this->buildPager($pager);
+ $this->onPagerCreated(new TActiveDataGridPagerEventParameter($pager));
+ $this->getControls()->add($pager);
+ return $pager;
+ }
+
/**
* Renders the datagrid.
* If the datagrid did not pass the prerender phase yet, it will register itself for rendering later.
@@ -765,3 +778,52 @@ class TActiveLiteralColumn extends TLiteralColumn {
}
}
}
+
+/**
+ * TActiveDataGridPager class.
+ *
+ * TActiveDataGridPager represents a pager in an activedatagrid.
+ *
+ * @author Fabio Bas <ctrlaltca@gmail.com>
+ * @version $Id: TDataGrid.php 3057 2011-11-09 12:35:57Z ctrlaltca@gmail.com $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.2.1
+ */
+class TActiveDataGridPager extends TDataGridPager
+{
+ protected $_callbackoptions;
+
+ /**
+ * @return TCallbackClientSide client side request options.
+ */
+ public function getClientSide()
+ {
+ if($this->_callbackoptions === null)
+ $this->_callbackoptions = new TCallbackOptions;
+ return $this->_callbackoptions->getClientSide();
+ }
+}
+
+/**
+ * TActiveDataGridPagerEventParameter class
+ *
+ * TActiveDataGridPagerEventParameter encapsulates the parameter data for
+ * {@link TActiveDataGrid::onPagerCreated OnPagerCreated} event of {@link TActiveDataGrid} controls.
+ * The {@link getPager Pager} property indicates the datagrid pager related with the event.
+ *
+ * @author Fabio Bas <ctrlaltca@gmail.com>
+ * @version $Id: TActiveDataGrid.php 3057 2011-11-09 12:35:57Z ctrlaltca@gmail.com $
+ * @package System.Web.UI.ActiveControls
+ * @since 3.2.1
+ */
+class TActiveDataGridPagerEventParameter extends TDataGridPagerEventParameter
+{
+ /**
+ * Constructor.
+ * @param TActiveDataGridPager datagrid pager related with the corresponding event
+ */
+ public function __construct(TActiveDataGridPager $pager)
+ {
+ $this->_pager=$pager;
+ }
+}
diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php
index ede67b89..9069f18d 100644
--- a/framework/Web/UI/WebControls/TDataGrid.php
+++ b/framework/Web/UI/WebControls/TDataGrid.php
@@ -1202,7 +1202,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
}
}
- private function createPager()
+ protected function createPager()
{
$pager=new TDataGridPager($this);
$this->buildPager($pager);
@@ -1233,6 +1233,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
* Depending on the button type, a TLinkButton or a TButton may be created.
* If it is enabled (clickable), its command name and parameter will also be set.
* Derived classes may override this method to create additional types of buttons, such as TImageButton.
+ * @param mixed the container pager instance of TActiveDatagridPager
* @param string button type, either LinkButton or PushButton
* @param boolean whether the button should be enabled
* @param string caption of the button
@@ -1240,7 +1241,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
* @param string CommandParameter corresponding to the OnCommand event of the button
* @return mixed the button instance
*/
- protected function createPagerButton($buttonType,$enabled,$text,$commandName,$commandParameter)
+ protected function createPagerButton($pager,$buttonType,$enabled,$text,$commandName,$commandParameter)
{
if($buttonType===TDataGridPagerButtonType::LinkButton)
{
@@ -1280,46 +1281,46 @@ class TDataGrid extends TBaseDataList implements INamingContainer
{
if(($text=$style->getFirstPageText())!=='')
{
- $label=$this->createPagerButton($buttonType,false,$text,'','');
+ $label=$this->createPagerButton($pager,$buttonType,false,$text,'','');
$controls->add($label);
$controls->add("\n");
}
- $label=$this->createPagerButton($buttonType,false,$style->getPrevPageText(),'','');
+ $label=$this->createPagerButton($pager,$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);
+ $button=$this->createPagerButton($pager,$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);
+ $button=$this->createPagerButton($pager,$buttonType,true,$style->getPrevPageText(),self::CMD_PAGE,self::CMD_PAGE_PREV);
$controls->add($button);
}
$controls->add("\n");
if($currentPageIndex===$this->getPageCount()-1)
{
- $label=$this->createPagerButton($buttonType,false,$style->getNextPageText(),'','');
+ $label=$this->createPagerButton($pager,$buttonType,false,$style->getNextPageText(),'','');
$controls->add($label);
if(($text=$style->getLastPageText())!=='')
{
$controls->add("\n");
- $label=$this->createPagerButton($buttonType,false,$text,'','');
+ $label=$this->createPagerButton($pager,$buttonType,false,$text,'','');
$controls->add($label);
}
}
else
{
- $button=$this->createPagerButton($buttonType,true,$style->getNextPageText(),self::CMD_PAGE,self::CMD_PAGE_NEXT);
+ $button=$this->createPagerButton($pager,$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);
+ $button=$this->createPagerButton($pager,$buttonType,true,$text,self::CMD_PAGE,self::CMD_PAGE_LAST);
$controls->add($button);
}
}
@@ -1356,12 +1357,12 @@ class TDataGrid extends TBaseDataList implements INamingContainer
{
if(($text=$style->getFirstPageText())!=='')
{
- $button=$this->createPagerButton($buttonType,true,$text,self::CMD_PAGE,self::CMD_PAGE_FIRST);
+ $button=$this->createPagerButton($pager,$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");
+ $button=$this->createPagerButton($pager,$buttonType,true,$style->getPrevPageText(),self::CMD_PAGE,"$prevPageIndex");
$controls->add($button);
$controls->add("\n");
}
@@ -1370,12 +1371,12 @@ class TDataGrid extends TBaseDataList implements INamingContainer
{
if($i===$pageIndex)
{
- $label=$this->createPagerButton($buttonType,false,"$i",'','');
+ $label=$this->createPagerButton($pager,$buttonType,false,"$i",'','');
$controls->add($label);
}
else
{
- $button=$this->createPagerButton($buttonType,true,"$i",self::CMD_PAGE,"$i");
+ $button=$this->createPagerButton($pager,$buttonType,true,"$i",self::CMD_PAGE,"$i");
$controls->add($button);
}
if($i<$endPageIndex)
@@ -1386,12 +1387,12 @@ class TDataGrid extends TBaseDataList implements INamingContainer
{
$controls->add("\n");
$nextPageIndex=$endPageIndex+1;
- $button=$this->createPagerButton($buttonType,true,$style->getNextPageText(),self::CMD_PAGE,"$nextPageIndex");
+ $button=$this->createPagerButton($pager,$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);
+ $button=$this->createPagerButton($pager,$buttonType,true,$text,self::CMD_PAGE,self::CMD_PAGE_LAST);
$controls->add($button);
}
}
@@ -1727,7 +1728,7 @@ class TDataGridPagerEventParameter extends TEventParameter
* The TDataGridPager control responsible for the event.
* @var TDataGridPager
*/
- private $_pager=null;
+ protected $_pager=null;
/**
* Constructor.