Prado\Web\UI\WebControls\TDataGridColumn::initializeHeaderCell PHP Method

initializeHeaderCell() protected method

This method attempts to use {@link getHeaderRenderer HeaderRenderer} to instantiate the header cell. If that is not available, it will populate the cell with an image or a text string, depending on {@link getHeaderImageUrl HeaderImageUrl} and {@link getHeaderText HeaderText} property values. If the column allows sorting, image or text will be created as a button which issues Sort command upon user click.
protected initializeHeaderCell ( $cell, $columnIndex )
    protected function initializeHeaderCell($cell, $columnIndex)
    {
        $text = $this->getHeaderText();
        if (($classPath = $this->getHeaderRenderer()) !== '') {
            $control = Prado::createComponent($classPath);
            $cell->getControls()->add($control);
            if ($control instanceof \Prado\IDataRenderer) {
                if ($control instanceof IItemDataRenderer) {
                    $item = $cell->getParent();
                    $control->setItemIndex($item->getItemIndex());
                    $control->setItemType($item->getItemType());
                }
                $control->setData($text);
            }
        } else {
            if ($this->getAllowSorting()) {
                $sortExpression = $this->getSortExpression();
                if (($url = $this->getHeaderImageUrl()) !== '') {
                    $button = new TImageButton();
                    $button->setImageUrl($url);
                    $button->setCommandName(TDataGrid::CMD_SORT);
                    $button->setCommandParameter($sortExpression);
                    if ($text !== '') {
                        $button->setAlternateText($text);
                    }
                    $button->setCausesValidation(false);
                    $cell->getControls()->add($button);
                } else {
                    if ($text !== '') {
                        $button = new TLinkButton();
                        $button->setText($text);
                        $button->setCommandName(TDataGrid::CMD_SORT);
                        $button->setCommandParameter($sortExpression);
                        $button->setCausesValidation(false);
                        $cell->getControls()->add($button);
                    } else {
                        $cell->setText(' ');
                    }
                }
            } else {
                if (($url = $this->getHeaderImageUrl()) !== '') {
                    $image = new TImage();
                    $image->setImageUrl($url);
                    if ($text !== '') {
                        $image->setAlternateText($text);
                    }
                    $cell->getControls()->add($image);
                } else {
                    if ($text !== '') {
                        $cell->setText($text);
                    } else {
                        $cell->setText(' ');
                    }
                }
            }
        }
    }