Example #1
0
 protected function GetControlHtml()
 {
     $strToReturn = '';
     $this->DataBind();
     // Table Tag
     $strStyle = $this->GetStyleAttributes();
     if ($strStyle) {
         $strStyle = sprintf('style="%s" ', $strStyle);
     }
     $strToReturn .= sprintf('<table %s%s>', $this->GetAttributes(), $strStyle);
     if ($this->objColumnArray) {
         foreach ($this->objColumnArray as $objColumn) {
             if ($this->ShowColumnToggle && $objColumn instanceof QDataGridColumnExt) {
                 // Check if this user has a display preference for this particular column
                 if ($objDatagridColumnPreference = DatagridColumnPreference::LoadByDatagridShortDescriptionColumnNameUserAccountId($this->Name, $objColumn->Name, QApplication::$objUserAccount->UserAccountId)) {
                     // Set the columns display attribute only if this user has a display preference set for this column
                     $objColumn->Display = $objDatagridColumnPreference->DisplayFlag;
                 }
             }
         }
     }
     // Paginator Row (if applicable)
     if ($this->objPaginator) {
         $strToReturn .= $this->GetPaginatorRowHtml($this->objPaginator);
     }
     // Header Row (if applicable)
     if ($this->blnShowHeader) {
         $strToReturn .= $this->GetHeaderRowHtml();
     }
     // DataGrid Rows
     $this->intCurrentRowIndex = 0;
     if ($this->objDataSource) {
         foreach ($this->objDataSource as $objObject) {
             $strToReturn .= $this->GetDataGridRowHtml($objObject);
         }
     }
     // Footer Row (if applicable)
     if ($this->blnShowFooter) {
         $strToReturn .= $this->GetFooterRowHtml();
     }
     // Finish Up
     $strToReturn .= '</table>';
     // Render the ColumnToggleMenu
     if ($this->blnShowColumnToggle || $this->ShowExportCsv) {
         $strToReturn .= $this->objColumnToggle->Render(false);
     }
     $this->objDataSource = null;
     return $strToReturn;
 }
 public function SaveDisplayPreference($strDatagridName)
 {
     $objDatagridColumnPreference = DatagridColumnPreference::LoadByDatagridShortDescriptionColumnNameUserAccountId($strDatagridName, $this->Name, QApplication::$objUserAccount->UserAccountId);
     if (!$objDatagridColumnPreference) {
         $objDatagridColumnPreference = new DatagridColumnPreference();
         $objDatagrid = Datagrid::LoadByShortDescription($strDatagridName);
         if ($objDatagrid) {
             $objDatagridColumnPreference->DatagridId = $objDatagrid->DatagridId;
         } else {
             throw new Exception(sprintf("The datagrid %s is not represented in the database", $strDatagridName));
         }
         $objDatagridColumnPreference->ColumnName = $this->Name;
         $objDatagridColumnPreference->UserAccountId = QApplication::$objUserAccount->UserAccountId;
     }
     $objDatagridColumnPreference->DisplayFlag = $this->Display;
     $objDatagridColumnPreference->Save();
 }