public function btnEdit_Click($strFormId, $strControlId, $strParameter)
 {
     $strParameterArray = explode(',', $strParameter);
     $objDatagrid = Datagrid::Load($strParameterArray[0]);
     $objEditPanel = new DatagridEditPanel($this, $this->strCloseEditPanelMethod, $objDatagrid);
     $strMethodName = $this->strSetEditPanelMethod;
     $this->objForm->{$strMethodName}($objEditPanel);
 }
 protected function SetupDatagrid()
 {
     // Lookup Object PK information from Query String (if applicable)
     // Set mode to Edit or New depending on what's found
     $intDatagridId = QApplication::QueryString('intDatagridId');
     if ($intDatagridId) {
         $this->objDatagrid = Datagrid::Load($intDatagridId);
         if (!$this->objDatagrid) {
             throw new Exception('Could not find a Datagrid object with PK arguments: ' . $intDatagridId);
         }
         $this->strTitleVerb = QApplication::Translate('Edit');
         $this->blnEditMode = true;
     } else {
         $this->objDatagrid = new Datagrid();
         $this->strTitleVerb = QApplication::Translate('Create');
         $this->blnEditMode = false;
     }
 }
 /**
  * Override method to perform a property "Get"
  * This will get the value of $strName
  *
  * @param string $strName Name of the property to get
  * @return mixed
  */
 public function __get($strName)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'DatagridColumnPreferenceId':
             /**
              * Gets the value for intDatagridColumnPreferenceId (Read-Only PK)
              * @return integer
              */
             return $this->intDatagridColumnPreferenceId;
         case 'DatagridId':
             /**
              * Gets the value for intDatagridId (Not Null)
              * @return integer
              */
             return $this->intDatagridId;
         case 'ColumnName':
             /**
              * Gets the value for strColumnName (Not Null)
              * @return string
              */
             return $this->strColumnName;
         case 'UserAccountId':
             /**
              * Gets the value for intUserAccountId (Not Null)
              * @return integer
              */
             return $this->intUserAccountId;
         case 'DisplayFlag':
             /**
              * Gets the value for blnDisplayFlag (Not Null)
              * @return boolean
              */
             return $this->blnDisplayFlag;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'Datagrid':
             /**
              * Gets the value for the Datagrid object referenced by intDatagridId (Not Null)
              * @return Datagrid
              */
             try {
                 if (!$this->objDatagrid && !is_null($this->intDatagridId)) {
                     $this->objDatagrid = Datagrid::Load($this->intDatagridId);
                 }
                 return $this->objDatagrid;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'UserAccount':
             /**
              * Gets the value for the UserAccount object referenced by intUserAccountId (Not Null)
              * @return UserAccount
              */
             try {
                 if (!$this->objUserAccount && !is_null($this->intUserAccountId)) {
                     $this->objUserAccount = UserAccount::Load($this->intUserAccountId);
                 }
                 return $this->objUserAccount;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             ////////////////////////////
             // Virtual Object References (Many to Many and Reverse References)
             // (If restored via a "Many-to" expansion)
             ////////////////////////////
         ////////////////////////////
         // Virtual Object References (Many to Many and Reverse References)
         // (If restored via a "Many-to" expansion)
         ////////////////////////////
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
Пример #4
0
 /**
  * Reload this Datagrid from the database.
  * @return void
  */
 public function Reload()
 {
     // Make sure we are actually Restored from the database
     if (!$this->__blnRestored) {
         throw new QCallerException('Cannot call Reload() on a new, unsaved Datagrid object.');
     }
     // Reload the Object
     $objReloaded = Datagrid::Load($this->intDatagridId);
     // Update $this's local variables to match
     $this->strShortDescription = $objReloaded->strShortDescription;
 }
 /**
  * Static Helper Method to Create using PK arguments
  * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
  * edit, or if we are also allowed to create a new one, etc.
  * 
  * @param mixed $objParentObject QForm or QPanel which will be using this DatagridMetaControl
  * @param integer $intDatagridId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing Datagrid object creation - defaults to CreateOrEdit
  * @return DatagridMetaControl
  */
 public static function Create($objParentObject, $intDatagridId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intDatagridId)) {
         $objDatagrid = Datagrid::Load($intDatagridId);
         // Datagrid was found -- return it!
         if ($objDatagrid) {
             return new DatagridMetaControl($objParentObject, $objDatagrid);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a Datagrid object with PK arguments: ' . $intDatagridId);
             }
         }
         // If EditOnly is specified, throw an exception
     } else {
         if ($intCreateType == QMetaControlCreateType::EditOnly) {
             throw new QCallerException('No PK arguments specified');
         }
     }
     // If we are here, then we need to create a new record
     return new DatagridMetaControl($objParentObject, new Datagrid());
 }