kartik\grid\GridView::renderExport PHP Méthode

renderExport() public méthode

Renders the export menu.
public renderExport ( ) : string
Résultat string
    public function renderExport()
    {
        if ($this->export === false || !is_array($this->export) || empty($this->exportConfig) || !is_array($this->exportConfig)) {
            return '';
        }
        $title = $this->export['label'];
        $icon = $this->export['icon'];
        $options = $this->export['options'];
        $menuOptions = $this->export['menuOptions'];
        $iconPrefix = $this->export['fontAwesome'] ? 'fa fa-' : 'glyphicon glyphicon-';
        $title = $icon == '' ? $title : "<i class='{$iconPrefix}{$icon}'></i> {$title}";
        $action = $this->_module->downloadAction;
        $encoding = ArrayHelper::getValue($this->export, 'encoding', 'utf-8');
        $bom = ArrayHelper::getValue($this->export, 'bom', true);
        $target = ArrayHelper::getValue($this->export, 'target', self::TARGET_POPUP);
        $form = Html::beginForm(is_array($action) ? $action : [$action], 'post', ['class' => 'kv-export-form', 'style' => 'display:none', 'target' => $target == self::TARGET_POPUP ? 'kvDownloadDialog' : $target]) . "\n" . Html::hiddenInput('export_filetype') . "\n" . Html::hiddenInput('export_filename') . "\n" . Html::hiddenInput('export_mime') . "\n" . Html::hiddenInput('export_config') . "\n" . Html::hiddenInput('export_encoding', $encoding) . "\n" . Html::hiddenInput('export_bom', $bom) . "\n" . Html::textarea('export_content') . "\n</form>";
        $items = empty($this->export['header']) ? [] : [$this->export['header']];
        foreach ($this->exportConfig as $format => $setting) {
            $iconOptions = ArrayHelper::getValue($setting, 'iconOptions', []);
            Html::addCssClass($iconOptions, $iconPrefix . $setting['icon']);
            $label = empty($setting['icon']) || $setting['icon'] == '' ? $setting['label'] : Html::tag('i', '', $iconOptions) . ' ' . $setting['label'];
            $items[] = ['label' => $label, 'url' => '#', 'linkOptions' => ['class' => 'export-' . $format, 'data-format' => ArrayHelper::getValue($setting, 'mime', 'text/plain')], 'options' => $setting['options']];
        }
        $itemsBefore = ArrayHelper::getValue($this->export, 'itemsBefore', []);
        $itemsAfter = ArrayHelper::getValue($this->export, 'itemsAfter', []);
        $items = ArrayHelper::merge($itemsBefore, $items, $itemsAfter);
        return ButtonDropdown::widget(['label' => $title, 'dropdown' => ['items' => $items, 'encodeLabels' => false, 'options' => $menuOptions], 'options' => $options, 'containerOptions' => $this->exportContainer, 'encodeLabel' => false]) . $form;
    }