コード例 #1
0
 public function RenderGrid(Grid $Grid)
 {
     $page = $Grid->GetPage();
     // Remove!!!
     if (isset($page->AdvancedSearchControl)) {
         $linkBuilder = $page->CreateLinkBuilder();
         $linkBuilder->AddParameter(OPERATION_PARAMNAME, OPERATION_ADVANCED_SEARCH);
         $page->AdvancedSearchControl->SetOpenInNewWindowLink($linkBuilder->GetLink());
     }
     $templates = array(ViewMode::TABLE => array('grid' => 'list/grid.tpl', 'single' => 'list/single_row.tpl'), ViewMode::CARD => array('grid' => 'list/grid_card.tpl', 'single' => 'list/single_row_card.tpl'));
     $selectedTemplates = $templates[$Grid->GetViewMode()];
     $template = $this->renderSingleRow ? $selectedTemplates['single'] : $selectedTemplates['grid'];
     $customParams = array();
     if (!$this->renderSingleRow) {
         $template = $page->GetCustomTemplate(PagePart::Grid, PageMode::ViewAll, $template, $customParams);
     }
     $this->DisplayTemplate($template, array('Grid' => $Grid, 'Page' => $Grid->GetPage(), 'DataGrid' => $Grid->GetViewData($this)), array_merge($customParams, array('isMasterGrid' => $Grid->GetName() == 'master_grid', 'SingleRowTemplate' => $page->GetCustomTemplate(PagePart::GridRow, PageMode::ViewAll, $selectedTemplates['single']), 'AdvancedSearchControl' => $page->AdvancedSearchControl, 'HiddenValues' => $Grid->GetHiddenValues(), 'TextsForHighlight' => $page->AdvancedSearchControl ? array_map(Q::L('($v) => StringUtils::JSStringLiteral($v)'), $page->AdvancedSearchControl->GetHighlightedFieldText()) : array(), 'HighlightOptions' => $page->AdvancedSearchControl ? $page->AdvancedSearchControl->GetHighlightedFieldOptions() : array(), 'Authentication' => $page->GetAuthenticationViewData(), 'Columns' => $Grid->GetViewColumns(), 'Bands' => $Grid->GetViewBands(), 'FilterBuilder' => $Grid->GetFilterBuilder()->GetViewData(), 'ActiveFilterBuilderJson' => $Grid->GetFilterBuilder()->GetActiveFilterAsJson(), 'ActiveFilterBuilderAsString' => $Grid->GetFilterBuilder()->GetActiveFilterAsString(), 'IsActiveFilterEmpty' => $Grid->GetFilterBuilder()->IsEmpty(), 'EnableRunTimeCustomization' => $Grid->getEnableRunTimeCustomization(), 'ViewModes' => ViewMode::getList())));
 }
コード例 #2
0
 public function GetViewData(Renderer $renderer)
 {
     $bandsViewData = array();
     foreach ($this->GetViewBands() as $band) {
         $bandsViewData[] = $band->GetViewData();
     }
     $actionsViewData = $this->getActions()->getViewData();
     $rows = array();
     $emptyGridMessage = $this->GetPage()->GetLocalizerCaptions()->GetMessageString('NoDataToDisplay');
     if ($this->RequestFilterFromUser()) {
         $emptyGridMessage = $this->GetPage()->GetLocalizerCaptions()->GetMessageString('CreateFilterConditionFirst');
     } else {
         $rows = $this->GetRowsViewData($renderer);
     }
     $sortableColumns = array();
     $sortableColumnsForJSON = array();
     foreach ($bandsViewData as $band) {
         foreach ($band['Columns'] as $column) {
             if ($column['Sortable']) {
                 $sortableColumn = array('name' => $column['Name'], 'index' => $column['SortIndex'], 'caption' => $column['Caption']);
                 $sortableColumns[$column['Name']] = $sortableColumn;
                 $sortableColumnsForJSON[$column['Name']] = array_merge($sortableColumn, array('caption' => StringUtils::ConvertTextToEncoding($column['Caption'], $this->getPage()->getContentEncoding(), 'UTF-8')));
             }
         }
     }
     return array('SortableColumns' => $sortableColumns, 'SortableColumnsJSON' => json_encode($sortableColumnsForJSON), 'Id' => $this->GetId(), 'MaxWidth' => $this->GetWidth(), 'Classes' => $this->GetGridClasses(), 'Attributes' => $this->GetAdditionalAttributes(), 'HiddenValuesJson' => $this->GetHiddenValuesJson(), 'EmptyGridMessage' => $emptyGridMessage, 'FilterBuilder' => $this->GetShowFilterBuilder() ? $this->GetFilterBuilder()->GetViewData() : null, 'QuickFilter' => $this->GetQuickFilter()->GetViewData(), 'AllowQuickFilter' => $this->GetPage()->GetSimpleSearchAvailable() && $this->UseFilter, 'ActionsPanelAvailable' => $this->GetPage()->GetSimpleSearchAvailable() && $this->UseFilter || $this->GetShowAddButton() || $this->GetShowInlineAddButton() || $this->GetAllowDeleteSelected() || $this->GetShowUpdateLink(), 'Links' => array('ModalInsertDialog' => $this->GetOpenInsertModalDialogLink(), 'InlineEditRequest' => $this->GetInlineEditRequestsAddress(), 'SimpleAddNewRow' => $this->GetAddRecordLink(), 'Refresh' => $this->GetUpdateLink()), 'ActionsPanel' => array('InlineAdd' => $this->GetShowInlineAddButton(), 'AddNewButton' => $this->GetShowAddButton() ? $this->GetUseModalInserting() ? 'modal' : 'simple' : null, 'RefreshButton' => $this->GetShowUpdateLink(), 'DeleteSelectedButton' => $this->GetAllowDeleteSelected()), 'ColumnCount' => count($this->GetViewColumns()) + ($this->GetAllowDeleteSelected() ? 1 : 0) + ($this->GetShowLineNumbers() ? 1 : 0) + ($this->GetHasDetails() ? 1 : 0) + ($actionsViewData ? 1 : 0), 'Bands' => $bandsViewData, 'Actions' => $actionsViewData, 'HasDetails' => $this->GetHasDetails(), 'UseInlineEdit' => $this->GetEnabledInlineEditing(), 'HighlightRowAtHover' => $this->GetHighlightRowAtHover(), 'AllowDeleteSelected' => $this->GetAllowDeleteSelected(), 'ShowLineNumbers' => $this->GetShowLineNumbers(), 'Rows' => $rows, 'Totals' => $this->GetTotalsViewData(), 'GridMessage' => $this->GetGridMessage() == '' ? null : $this->GetGridMessage(), 'ErrorMessage' => $this->GetErrorMessage() == '' ? null : $this->GetErrorMessage(), 'DataSortPriority' => $this->getSortedColumns(), 'EnableRunTimeCustomization' => $this->getEnableRunTimeCustomization(), 'ViewModeList' => ViewMode::getList(), 'ViewMode' => $this->GetViewMode(), 'CardCountInRow' => $this->GetCardCountInRow(), 'CardClasses' => $this->getCardClasses());
 }