Função geradora do cabeçalho do datagrid
@return string
193604
private function gridHeaderBuild() {
        $html = '<thead class="table-header">' . self::$phpEOL;

        $html .= $this->gridHeaderLabel();
        if ($this->searchEnable) {
            $html .= $this->gridHeaderSearch();
        }

        $html .= '</thead>' . self::$phpEOL;

        return $html;
    }
197749
protected function getColumnsDefinition()
    {
        $config  = $this->config->get('datatables.columns');
        $allowed = ['excess', 'escape', 'raw', 'blacklist', 'whitelist'];

        return array_replace_recursive(array_only($config, $allowed), $this->columnDef);
    }
37358
public function renderColumnLabel(Column $column): string
    {
        $label = $column->getLabel();
        if (!$label) {
            $key = "datagrid.{$column->getDataGrid()->getCode()}.{$column->getCode()}";
            if ($this->translator instanceof TranslatorBagInterface
                && $this->translator->getCatalogue()
                && $this->translator->getCatalogue()->has($key)
            ) {
                $label = $key;
            } else {
                $label = ucfirst(
                    strtolower(trim(preg_replace(['/([A-Z])/', '/[_\s]+/'], ['_$1', ' '], $column->getCode())))
                );
            }
        }

        return $this->translator->trans($label);
    }
1152213
public function toString()
    {
        $adapter = $this->getAdapter();
        $prefix  = $adapter->getTablePrefix();
        $query   = 'SELECT';

        if($this->columns)
        {
            if($this->distinct) {
                $query .= ' DISTINCT';
            }

            $columns = array();
            foreach($this->columns as $alias => $column)
            {
                if($column instanceof KDatabaseQuerySelect) {
                    $columns[] = '('.$column.')'.(is_string($alias) ? ' AS '.$adapter->quoteIdentifier($alias) : '');
                } else {
                    $columns[] = $adapter->quoteIdentifier($column.(is_string($alias) ? ' AS '.$alias : ''));
                }
            }

            $query .= ' '.implode(', ', $columns);
        }
        else $query .= ' *';

        if($this->table)
        {
            if(current($this->table) instanceof KDatabaseQuerySelect) {
                $table= '('.current($this->table).')'.(!is_numeric(key($this->table)) ? ' AS '.$adapter->quoteIdentifier(key($this->table)) : '');
            } else {
                $table = $adapter->quoteIdentifier($prefix.current($this->table).(!is_numeric(key($this->table)) ? ' AS '.key($this->table) : ''));
            }

            $query .= ' FROM '.$table;
        }

        if($this->join)
        {
            $joins = array();
            foreach($this->join as $alias => $join)
            {
                $tmp = '';

                if($join['type']) {
                    $tmp .= ' '.$join['type'];
                }

                if($join['table'] instanceof KDatabaseQuerySelect) {
                    $tmp .= ' JOIN ('.$join['table'].')'.(is_string($alias) ? ' AS '.$adapter->quoteIdentifier($alias) : '');
                } else {
                    $tmp .= ' JOIN '.$adapter->quoteIdentifier($prefix.$join['table'].(is_string($alias) ? ' AS '.$alias : ''));
                }

                if($join['condition']) {
                    $tmp .= ' ON ('.$adapter->quoteIdentifier($join['condition']).')';
                }

                $joins[] = $tmp;
            }

            $query .= implode('', $joins);
        }

        if($this->where)
        {
            $query .= ' WHERE';

            foreach($this->where as $where)
            {
                if($where['combination']) {
                    $query .= ' '.$where['combination'];
                }

                $query .= ' '. $adapter->quoteIdentifier($where['condition']);
            }
        }

        if($this->group)
        {
            $columns = array();
            foreach($this->group as $column) {
                $columns[] = $adapter->quoteIdentifier($column);
            }

            $query .= ' GROUP BY '.implode(' , ', $columns);
        }

        if($this->having)
        {
            $columns = array();
            foreach($this->having as $column) {
                $columns[] = $adapter->quoteIdentifier($column);
            }

            $query .= ' HAVING '.implode(' , ', $columns);
        }

        if($this->order)
        {
            $query .= ' ORDER BY ';

            $list = array();
            foreach($this->order as $order) {
                $list[] = $adapter->quoteIdentifier($order['column']).' '.$order['direction'];
            }

            $query .= implode(' , ', $list);
        }

        if($this->limit) {
            $query .= ' LIMIT '.$this->offset.' , '.$this->limit;
        }

        if($this->_parameters) {
            $query = $this->_replaceParams($query);
        }

        return $query;
    }
137066
public function renderHeaderCell()
	{
		if ($this->grid->json) {
			$header = array('id' => $this->id);
			$content = array();
			if ($this->grid->enableSorting && $this->sortable && $this->name !== null) {
				$sort = $this->grid->dataProvider->getSort();
				$label = isset($this->header) ? $this->header : $sort->resolveLabel($this->name);

				if ($sort->resolveAttribute($this->name) !== false) {
					$label .= '<span class="caret"></span>';
				}
				$content['content'] = $sort->link($this->name, $label, array('class' => 'sort-link'));
			} else {
				if ($this->name !== null && $this->header === null) {
					if ($this->grid->dataProvider instanceof CActiveDataProvider) {
						$content['content'] = CHtml::encode(
							$this->grid->dataProvider->model->getAttributeLabel($this->name)
						);
					} else {
						$content['content'] = CHtml::encode($this->name);
					}
				} else {
					$content['content'] = trim($this->header) !== '' ? $this->header
						: $this->grid->blankDisplay;
				}
			}
			return CMap::mergeArray($header, $content);
		}
		parent::renderHeaderCell();
	}
647021
public function datagridAttributes(array $attributes)
    {
        $result = '';

        foreach ($attributes as $attributeName => $attributeValue) {
            $result .= ' '.$attributeName.'="'.$attributeValue.'"';
        }

        return $result;
    }
202130
public function dataGrid ($dataGrid)
    {   
        if (!$dataGrid instanceof DataGridInterface){
            $dataGrid = $this->container->get('thrace_data_grid.provider')->get($dataGrid);
        }

        return $this->container->get('templating')->render(
            'ThraceDataGridBundle:DataGrid:index.html.twig', 
            array(
                'dataGrid' => $dataGrid, 
                'translationDomain' => $this->container
                    ->getParameter('thrace_data_grid.translation_domain')
            )
        );
    }
885938
public function getAreaLayoutColumnOffsetEditClass()
    {
        /*
         * @var ThemeGridLayout $this->arLayout
         */
        $gf = $this->arLayout->getThemeGridFrameworkObject();
        if (is_object($gf)) {
            $class = $gf->getPageThemeGridFrameworkColumnAdditionalClasses();
            if ($class) {
                $class .= ' ';
            }

            $class .= $gf->getPageThemeGridFrameworkColumnClassForSpan($this->arLayoutColumnOffset);

            return $class;
        }
    }
912565
public function renderDataGrid(DataGrid $dataGrid, array $viewParameters = []): string
    {
        $viewParameters = array_merge($dataGrid->getTemplateVars(), $viewParameters);
        $viewParameters['datagrid'] = $dataGrid;

        return $this->twig->render($dataGrid->getTemplate(), $viewParameters);
    }
27184
function RenderGrid()
	{
	global $gSQLBlockRows; // used by rs2html to indicate how many rows to display
		include_once(ADODB_DIR.'/tohtml.inc.php');
		ob_start();
		$gSQLBlockRows = $this->rows;
		rs2html($this->rs,$this->gridAttributes,$this->gridHeader,$this->htmlSpecialChars);
		$s = ob_get_contents();
		ob_end_clean();
		return $s;
	}
530350
public function getHeaderRowHTML()
    {
        $output = [];
        foreach ($this->columns as $name => $column) {

            // If multiple formatters are defined, use the first for the header cell
            if (is_array($column)) {
                $column = $column[0];
            }

            if (!is_int($name)) {
                $field = $this->model->getElement($name);

                $output[] = $column->getHeaderCellHTML($field);
            } else {
                $output[] = $column->getHeaderCellHTML();
            }
        }

        return implode('', $output);
    }
683643
public function getGrid($data, $row = 'tr', $col = 'td', $options = null)
    {
        $rows = '';

        if (!is_array($data)) {
            return $rows;
        }


        foreach ($data as $rowIndex => $rowValue) {

            // Attribute for tr
            $attributes[$row] = '';
            foreach ($options[$row] as $key => $value) {
                if ($key !== 'tag') {

                    $value = is_callable($value) ?
                        $value($rowIndex, $rowValue, $options) : $value;

                    $attributes[$row] .= !empty($value) ? ' ' . $key . '="' . $value . '"' : '';
                }
            }

            $cols = '';
            $skipCols = 0;
            $skipCols = $this->isShowRowIndex() ? $skipCols + 1 : $skipCols;
            $skipCols = $this->isShowRowCheckbox() ? $skipCols + 1 : $skipCols;

            $i = 0;
            foreach ($rowValue as $colIndex => $colValue) {

                // Attribute for td
                $attributes[$col] = '';
                foreach ($options[$col] as $key => $value) {
                    if ($key !== 'tag' && $key !== 'value') {

                        $value = is_callable($value) ?
                            $value($rowIndex, $colIndex, $colValue,
                                $options) : $value;

                        $attributes[$col] .= !empty($value) ? ' ' . $key . '="' . $value . '"' : '';
                    }
                }

                // Value for td
                if (($row == 'thead_tr' && !$this->theadUsesValue) ||
                    ($row == 'tfoot_tr' && !$this->tfootUsesValue)
                ) {
                    if ($rowIndex === 'search') {
                        $colValue = $i >= $skipCols ? $colValue : '';
                    } else {
                        $colValue = $i >= $skipCols ? $colIndex : '';
                    }

                } else {
                    $colValue = isset($options[$col]['value']) && is_callable($options[$col]['value']) ?
                        $options[$col]['value']($rowIndex, $colIndex,
                            $colValue,
                            $options) : $colValue;
                }

                $cols .= sprintf($options[$col]['tag'], $attributes[$col],
                    $colValue);

                $i++;
            }

            $rows .= sprintf($options[$row]['tag'], $attributes[$row], $cols);
        }

        return $rows;
    }
479688
public function getFieldEditorGrid()
    {
        Requirements::javascript('silverstripe/userforms:client/dist/js/userforms-cms.js');

        $fields = $this->owner->Fields();

        $this->createInitialFormStep(true);

        $editableColumns = new GridFieldEditableColumns();
        $fieldClasses = singleton(EditableFormField::class)->getEditableFieldClasses();
        $editableColumns->setDisplayFields([
            'ClassName' => function ($record, $column, $grid) use ($fieldClasses) {
                if ($record instanceof EditableFormField) {
                    return $record->getInlineClassnameField($column, $fieldClasses);
                }
            },
            'Title' => function ($record, $column, $grid) {
                if ($record instanceof EditableFormField) {
                    return $record->getInlineTitleField($column);
                }
            }
        ]);

        $config = GridFieldConfig::create()
            ->addComponents(
                $editableColumns,
                new GridFieldButtonRow(),
                (new GridFieldAddClassesButton(EditableTextField::class))
                    ->setButtonName(_t(__CLASS__.'.ADD_FIELD', 'Add Field'))
                    ->setButtonClass('btn-primary'),
                (new GridFieldAddClassesButton(EditableFormStep::class))
                    ->setButtonName(_t(__CLASS__.'.ADD_PAGE_BREAK', 'Add Page Break'))
                    ->setButtonClass('btn-secondary'),
                (new GridFieldAddClassesButton([EditableFieldGroup::class, EditableFieldGroupEnd::class]))
                    ->setButtonName(_t(__CLASS__.'.ADD_FIELD_GROUP', 'Add Field Group'))
                    ->setButtonClass('btn-secondary'),
                $editButton = new GridFieldEditButton(),
                new GridFieldDeleteAction(),
                new GridFieldToolbarHeader(),
                new GridFieldOrderableRows('Sort'),
                new GridFieldDetailForm()
            );

        $editButton->removeExtraClass('grid-field__icon-action--hidden-on-hover');

        $fieldEditor = GridField::create(
            'Fields',
            '',
            $fields,
            $config
        )->addExtraClass('uf-field-editor');

        return $fieldEditor;
    }
82986
protected function _sort()
    {
        if (!isset($this->_sorts) || count($this->_sorts) === 0) {
            return;
        }

        $columns      = $this->_dataGrid->getActiveColumnsOrdered();
        $sorts        = $this->_sorts;
        $sortPosition = $this->_sortPositions;

        usort($this->_output, function ($a, $b) use ($columns, $sortPosition, $sorts) {
            foreach ($sortPosition as $colIndex) {
                $sort = $sorts[$colIndex];
                /** @var $sort\RBM\Datagrid\Data\Sort */
                /** @var $column\RBM\Datagrid\Column */
                $column = $columns[$colIndex];
                $valueA = $column->getSortData($a);
                $valueB = $column->getSortData($b);

                if ($valueA == $valueB) {
                    continue;
                }

                $arr = array($valueA, $valueB);

                $args = array_merge(array(&$arr), array($sort->getDirection(), $sort->getType()));
                call_user_func_array('array_multisort', $args);

                return ($arr[0] == $valueA) ? -1 : 1;
            }
            return 0;
        });
    }
954845
public function render()
    {
        return $this->tools->map(function ($tool) {
            if ($tool instanceof AbstractTool) {
                if (!$tool->allowed()) {
                    return '';
                }

                return $tool->setGrid($this->grid)->render();
            }

            return (string) $tool;
        })->implode(' ');
    }
1193025
protected function getFullnameColumn()
    {
        return function ($row) {
            $roles = $row->roles;
            $value = [];

            foreach ($roles as $role) {
                $value[] = app('html')->create('span', e($role->name), [
                    'class' => 'label label-info',
                    'role' => 'role',
                ]);
            }

            return implode('', [
                app('html')->create('strong', e($row->fullname)),
                app('html')->create('br'),
                app('html')->create('span', app('html')->raw(implode(' ', $value)), [
                    'class' => 'meta',
                ]),
            ]);
        };
    }
275172
public function prepareViewModel(Datagrid $grid)
    {
        $viewModel = $this->getViewModel();

        $viewModel->setVariable('gridId', $grid->getId());
        $viewModel->setVariable('title', $this->getTitle());
        $viewModel->setVariable('parameters', $grid->getParameters());
        $viewModel->setVariable('overwriteUrl', $grid->getUrl());

        $viewModel->setVariable('templateToolbar', $this->getToolbarTemplate());
        foreach ($this->getToolbarTemplateVariables() as $key => $value) {
            $viewModel->setVariable($key, $value);
        }
        $viewModel->setVariable('rendererName', $this->getName());

        $options = $this->getOptions();
        $generalParameterNames = $options['generalParameterNames'];
        $viewModel->setVariable('generalParameterNames', $generalParameterNames);

        $viewModel->setVariable('columns', $this->getColumns());

        $viewModel->setVariable('rowStyles', $grid->getRowStyles());

        $viewModel->setVariable('paginator', $this->getPaginator());
        $viewModel->setVariable('data', $this->getData());
        $viewModel->setVariable('filters', $this->getFilters());

        $viewModel->setVariable('rowClickAction', $grid->getRowClickAction());
        $viewModel->setVariable('massActions', $grid->getMassActions());

        $viewModel->setVariable('isUserFilterEnabled', $grid->isUserFilterEnabled());

        /*
         * renderer specific parameter names
         */
        $optionsRenderer = $this->getOptionsRenderer();
        $viewModel->setVariable('optionsRenderer', $optionsRenderer);
        if ($this->isExport() === false) {
            $parameterNames = $optionsRenderer['parameterNames'];
            $viewModel->setVariable('parameterNames', $parameterNames);

            $activeParameters = [];
            $activeParameters[$parameterNames['currentPage']] = $this->getCurrentPageNumber();
            {
                $sortColumns = [];
                $sortDirections = [];
            foreach ($this->getSortConditions() as $sortCondition) {
                $sortColumns[] = $sortCondition['column']->getUniqueId();
                $sortDirections[] = $sortCondition['sortDirection'];
            }

                $activeParameters[$parameterNames['sortColumns']] = implode(',', $sortColumns);
                $activeParameters[$parameterNames['sortDirections']] = implode(',', $sortDirections);
            }
            $viewModel->setVariable('activeParameters', $activeParameters);
        }

        $viewModel->setVariable('exportRenderers', $grid->getExportRenderers());
    }