Exemple #1
0
 public function onInit($param)
 {
     parent::onInit($param);
     // Text Box
     $textBox = new TTextBox();
     $textBox->setVisible(false);
     $textBox->setID("MyTextBox");
     $this->panel1->getControls()->add($textBox);
     $this->registerObject("MyTextBox", $textBox);
     // Submit button
     $button = new TActiveButton();
     $button->setVisible(false);
     $button->setID("MyButton");
     $button->setText("Submit");
     $button->attachEventHandler("OnCallback", array($this, "clickedButton"));
     $this->panel1->getControls()->add($button);
     $this->registerObject("MyButton", $button);
 }
 /**
  * Creates a pager button.
  * Override parent implementation to create, depending on the button type, a TActiveLinkButton,
  * a TActiveButton or a TActiveImageButton may be created.
  * 
  * @param string button type, either LinkButton or PushButton
  * @param boolean whether the button should be enabled
  * @param string caption of the button
  * @param string CommandName corresponding to the OnCommand event of the button
  * @param string CommandParameter corresponding to the OnCommand event of the button
  * @return mixed the button instance
  */
 protected function createPagerButton($buttonType, $enabled, $text, $commandName, $commandParameter)
 {
     if ($buttonType === TPagerButtonType::LinkButton) {
         if ($enabled) {
             $button = new TActiveLinkButton();
         } else {
             $button = new TLabel();
             $button->setText($text);
             return $button;
         }
     } else {
         if ($buttonType === TPagerButtonType::ImageButton) {
             $button = new TActiveImageButton();
             $button->setImageUrl($this->getPageImageUrl($text, $commandName));
             if ($enabled) {
                 $button->Visible = true;
             } else {
                 $button->Visible = false;
             }
         } else {
             $button = new TActiveButton();
             if (!$enabled) {
                 $button->setEnabled(false);
             }
         }
     }
     if ($buttonType === TPagerButtonType::ImageButton) {
         $button->ImageUrl = $text;
     }
     $button->setText($text);
     $button->setCommandName($commandName);
     $button->setCommandParameter($commandParameter);
     $button->setCausesValidation(false);
     $button->attachEventHandler('OnCallback', array($this, 'handleCallback'));
     $button->getAdapter()->getBaseActiveControl()->setClientSide($this->getClientSide());
     return $button;
 }
 /**
  * Creates a pager button.
  * Depending on the button type, a TActiveLinkButton or a TActiveButton may be created.
  * 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
  * @param string CommandName corresponding to the OnCommand event of the button
  * @param string CommandParameter corresponding to the OnCommand event of the button
  * @return mixed the button instance
  */
 protected function createPagerButton($pager, $buttonType, $enabled, $text, $commandName, $commandParameter)
 {
     if ($buttonType === TDataGridPagerButtonType::LinkButton) {
         if ($enabled) {
             $button = new TActiveLinkButton();
         } else {
             $button = new TLabel();
             $button->setText($text);
             return $button;
         }
     } else {
         $button = new TActiveButton();
         if (!$enabled) {
             $button->setEnabled(false);
         }
     }
     $button->setText($text);
     $button->setCommandName($commandName);
     $button->setCommandParameter($commandParameter);
     $button->setCausesValidation(false);
     $button->getAdapter()->getBaseActiveControl()->setClientSide($pager->getClientSide());
     return $button;
 }