Inheritance: extends QBaseClass
 protected function dtgProjects_Create()
 {
     // Define the DataGrid
     $this->dtgProjects = new QDataGrid($this);
     $this->dtgProjects->ShowFilter = true;
     // To create pagination, we will create a new paginator, and specify the datagrid
     // as the paginator's parent.  (We do this because the datagrid is the control
     // who is responsible for rendering the paginator, as opposed to the form.)
     $objPaginator = new QPaginator($this->dtgProjects);
     $this->dtgProjects->Paginator = $objPaginator;
     // Now, with a paginator defined, we can set up some additional properties on
     // the datagrid.  For purposes of this example, let's make the datagrid show
     // only 5 items per page.
     $this->dtgProjects->ItemsPerPage = 20;
     // Define Columns
     //Project Name
     $colName = new QDataGridColumn('Project', '<?= $_ITEM->Name?>');
     $colName->OrderByClause = QQ::OrderBy(QQN::Project()->Name);
     $colName->ReverseOrderByClause = QQ::OrderBy(QQN::Project()->Name, false);
     $this->dtgProjects->AddColumn($colName);
     //Project type - filtered
     $colType = new QDataGridColumn('Type', '<?= ProjectStatusType::ToString($_ITEM->ProjectStatusTypeId) ?>');
     $colType->OrderByClause = QQ::OrderBy(QQN::Project()->ProjectStatusTypeId);
     $colType->ReverseOrderByClause = QQ::OrderBy(QQN::Project()->ProjectStatusTypeId, false);
     $colType->FilterType = QFilterType::ListFilter;
     foreach (ProjectStatusType::$NameArray as $value => $name) {
         $colType->FilterAddListItem($name, QQ::Equal(QQN::Project()->ProjectStatusTypeId, $value));
     }
     $this->dtgProjects->AddColumn($colType);
     //Manager First Name
     $colFName = new QDataGridColumn('First Name', '<?= $_ITEM->ManagerPerson->FirstName ?>');
     $colFName->OrderByClause = QQ::OrderBy(QQN::Project()->ManagerPerson->FirstName);
     $colFName->ReverseOrderByClause = QQ::OrderBy(QQN::Project()->ManagerPerson->FirstName, false);
     $this->dtgProjects->AddColumn($colFName);
     //Manager Last Name - filtered, only show with enabled logins
     $colLName = new QDataGridColumn('Last Name', '<?= $_ITEM->ManagerPerson->LastName ?>');
     $colLName->OrderByClause = QQ::OrderBy(QQN::Project()->ManagerPerson->LastName);
     $colLName->ReverseOrderByClause = QQ::OrderBy(QQN::Project()->ManagerPerson->LastName, false);
     QQN::Project()->ManagerPerson->LastName->SetFilteredDataGridColumnFilter($colLName);
     $colLName->FilterConstant = QQ::Equal(QQN::Project()->ManagerPerson->Login->IsEnabled, true);
     $this->dtgProjects->AddColumn($colLName);
     // Specify the Datagrid's Data Binder method
     $this->dtgProjects->SetDataBinder('dtgProjects_Bind');
     /*		 * *********************** */
     // Make the DataGrid look nice
     $objStyle = $this->dtgProjects->RowStyle;
     $objStyle->FontSize = 12;
     $objStyle = $this->dtgProjects->AlternateRowStyle;
     $objStyle->BackColor = '#f6f6f6';
     $objStyle = $this->dtgProjects->HeaderRowStyle;
     $objStyle->ForeColor = 'white';
     $objStyle->BackColor = '#780000';
     // Because browsers will apply different styles/colors for LINKs
     // We must explicitly define the ForeColor for the HeaderLink.
     // The header row turns into links when the column can be sorted.
     $objStyle = $this->dtgProjects->HeaderLinkStyle;
     $objStyle->ForeColor = 'white';
 }
 /**
  * Similar to MetaAddColumn, except it creates a column for a Type-based Id.  You MUST specify
  * the name of the Type class that this will attempt to use $NameArray against.
  * 
  * Also, $mixContent cannot be an array.  Only a single field can be specified.
  *
  * @param mixed $mixContent string or QQNode from Country
  * @param string $strTypeClassName the name of the TypeClass to use $NameArray against
  * @param mixed $objOverrideParameters
  */
 public function MetaAddTypeColumn($mixContent, $strTypeClassName, $objOverrideParameters = null)
 {
     // Validate TypeClassName
     if (!class_exists($strTypeClassName) || !property_exists($strTypeClassName, 'NameArray')) {
         throw new QCallerException('Invalid TypeClass Name: ' . $strTypeClassName);
     }
     // Validate Node
     try {
         $objNode = $this->ResolveContentItem($mixContent);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
     // Create the Column
     $strName = QConvertNotation::WordsFromCamelCase($objNode->_PropertyName);
     if (strtolower(substr($strName, strlen($strName) - 3)) == ' id') {
         $strName = substr($strName, 0, strlen($strName) - 3);
     }
     $strProperty = $objNode->GetDataGridHtml();
     $objNewColumn = new QDataGridColumn(QApplication::Translate($strName), sprintf('<?=(%s) ? %s::$NameArray[%s] : null;?>', $strProperty, $strTypeClassName, $strProperty), array('OrderByClause' => QQ::OrderBy($objNode), 'ReverseOrderByClause' => QQ::OrderBy($objNode, false)));
     // Perform Overrides
     $objOverrideArray = func_get_args();
     if (count($objOverrideArray) > 2) {
         try {
             unset($objOverrideArray[0]);
             unset($objOverrideArray[1]);
             $objNewColumn->OverrideAttributes($objOverrideArray);
         } catch (QCallerException $objExc) {
             $objExc->IncrementOffset();
             throw $objExc;
         }
     }
     $this->AddColumn($objNewColumn);
     return $objNewColumn;
 }
Example #3
0
 public function SetFilteredDataGridColumnFilter(QDataGridColumn $col)
 {
     switch ($this->strType) {
         case QDatabaseFieldType::Bit:
             //List of true / false / any
             $col->FilterType = QFilterType::ListFilter;
             $col->FilterAddListItem("True", QQ::Equal($this, true));
             $col->FilterAddListItem("False", QQ::Equal($this, false));
             $col->FilterAddListItem("Set", QQ::IsNotNull($this));
             $col->FilterAddListItem("Unset", QQ::IsNull($this));
             break;
         case QDatabaseFieldType::Blob:
         case QDatabaseFieldType::Char:
         case QDatabaseFieldType::Time:
         case QDatabaseFieldType::VarChar:
         case QDatabaseFieldType::Date:
         case QDatabaseFieldType::DateTime:
             //LIKE
             $col->FilterType = QFilterType::TextFilter;
             $col->FilterPrefix = '%';
             $col->FilterPostfix = '%';
             $col->Filter = QQ::Like($this, null);
             break;
         case QDatabaseFieldType::Float:
         case QDatabaseFieldType::Integer:
             //EQUAL
             $col->FilterType = QFilterType::TextFilter;
             $col->Filter = QQ::Equal($this, null);
             break;
         case QType::Object:
         case QType::Resource:
         default:
             //this node points to a class, there's no way to know what to filter on
             $col->FilterType = QFilterType::None;
             $col->ClearFilter();
             break;
     }
 }
 /**
  * Override method to perform a property "Set"
  * This will set the property $strName to be $mixValue
  *
  * @param string $strName Name of the property to set
  * @param string $mixValue New value of the property
  * @return mixed
  */
 public function __set($strName, $mixValue)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'PrimaryKey':
             /**
              * Sets the value for strPrimaryKey 
              * @param integer $mixValue
              * @return string
              */
             try {
                 return $this->strPrimaryKey = QType::Cast($mixValue, QType::String);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         default:
             try {
                 return parent::__set($strName, $mixValue);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 protected function CreateFilterControl($strControlId, QDataGridColumn $objColumn)
 {
     //show the current filter in the control
     $value = $objColumn->GetActiveFilterValue();
     #region Create the control
     //create the appropriate kind of control
     $actionName = 'btnFilter_Click';
     $ctlFilter = null;
     switch ($objColumn->FilterType) {
         default:
         case QFilterType::TextFilter:
             $ctlFilter = $this->filterTextBox_Create($strControlId, $objColumn->Name, $objColumn->FilterBoxSize, $value);
             break;
         case QFilterType::ListFilter:
             $ctlFilter = $this->filterListBox_Create($strControlId, $objColumn->Name, $objColumn->FilterList, $value);
             break;
     }
     #endregion
     if (null !== $ctlFilter) {
         //make sure hitting enter applies the filter
         if ($this->blnUseAjax) {
             $ctlFilter->AddAction(new QEnterKeyEvent(), new QAjaxControlAction($this, $actionName, $this->objWaitIcon));
         } else {
             $ctlFilter->AddAction(new QEnterKeyEvent(), new QServerControlAction($this, $actionName));
         }
         $ctlFilter->AddAction(new QEnterKeyEvent(), new QTerminateAction());
     }
     return $ctlFilter;
 }
 public function __set($strName, $mixValue)
 {
     switch ($strName) {
         // APPEARANCE
         case "Display":
             try {
                 $this->blnDisplay = QType::Cast($mixValue, QType::Boolean);
                 // $this->MarkAsWrapperModified();
                 break;
             } catch (QInvalidCastException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         default:
             try {
                 parent::__set($strName, $mixValue);
                 break;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }