Exemplo n.º 1
0
 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';
 }
Exemplo n.º 2
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;
     }
 }