예제 #1
0
    /**
     * @return string
     */
    public function renderAfterTable()
    {
        $id = $this->id;
        GridViewStandartAsset::register($this->view);
        $checkbox = Html::checkbox('sx-select-full-all', false, ['class' => 'sx-select-full-all']);
        $multiActions = [];
        if ($this->adminController) {
            $multiActions = $this->adminController->getMultiActions();
        }
        if (!$multiActions) {
            return parent::renderAfterTable();
        }
        $options = ['id' => $this->id, 'enabledPjax' => $this->enabledPjax, 'pjaxId' => $this->pjax->id, 'requestPkParamName' => $this->adminController->requestPkParamName];
        $optionsString = Json::encode($options);
        $gridJsObject = $this->getGridJsObject();
        $this->view->registerJs(<<<JS
        {$gridJsObject} = new sx.classes.grid.Standart({$optionsString});
JS
);
        $buttons = "";
        $additional = [];
        foreach ($multiActions as $action) {
            $additional[] = $action->registerForGrid($this);
            $buttons .= <<<HTML
            <button class="btn btn-default btn-sm sx-grid-multi-btn" data-id="{$action->id}">
                <i class="{$action->icon}"></i> {$action->name}
            </button>
HTML;
        }
        $additional = implode("", $additional);
        $this->afterTableLeft = <<<HTML
    {$checkbox} для всех
    <span class="sx-grid-multi-controlls">
        {$buttons}
    </span>
    <span style="display: none;">{$additional}</span>
HTML;
        $this->view->registerCss(<<<CSS
    .sx-grid-multi-controlls
    {
        margin-left: 20px;
    }
CSS
);
        return parent::renderAfterTable();
    }