kartik\grid\GridView::initLayout PHP Method

initLayout() protected method

Initialize the grid layout.
protected initLayout ( )
    protected function initLayout()
    {
        Html::addCssClass($this->filterRowOptions, 'skip-export');
        if ($this->resizableColumns && $this->persistResize) {
            $key = empty($this->resizeStorageKey) ? Yii::$app->user->id : $this->resizeStorageKey;
            $gridId = empty($this->options['id']) ? $this->getId() : $this->options['id'];
            $this->containerOptions['data-resizable-columns-id'] = empty($key) ? "kv-{$gridId}" : "kv-{$key}-{$gridId}";
        }
        if ($this->hideResizeMobile) {
            Html::addCssClass($this->options, 'hide-resize');
        }
        $export = $this->renderExport();
        $toggleData = $this->renderToggleData();
        $toolbar = strtr($this->renderToolbar(), ['{export}' => $export, '{toggleData}' => $toggleData]);
        $replace = ['{toolbar}' => $toolbar];
        if (strpos($this->layout, '{export}') > 0) {
            $replace['{export}'] = $export;
        }
        if (strpos($this->layout, '{toggleData}') > 0) {
            $replace['{toggleData}'] = $toggleData;
        }
        $this->layout = strtr($this->layout, $replace);
        $this->layout = str_replace('{items}', Html::tag('div', '{items}', $this->containerOptions), $this->layout);
        if (is_array($this->replaceTags) && !empty($this->replaceTags)) {
            foreach ($this->replaceTags as $key => $value) {
                if ($value instanceof \Closure) {
                    $value = call_user_func($value, $this);
                }
                $this->layout = str_replace($key, $value, $this->layout);
            }
        }
    }

Usage Example

Beispiel #1
0
 protected function initLayout()
 {
     $this->resizeStorageKey = empty($this->resizeStorageKey) ? date('Ymd') : $this->resizeStorageKey;
     parent::initLayout();
 }