Home > Backend Development > PHP Tutorial > Yii2 的 GridView 如何生成批量操作按钮

Yii2 的 GridView 如何生成批量操作按钮

WBOY
Release: 2016-06-06 20:33:58
Original
1181 people have browsed it

使用yii2 生成管理列表,有 CheckboxColumns::className()这个可以生成复选框,但这个“批量提交”的按钮是放到哪里?我想把批量删除的按钮放在GridView 生成的<table><tfooter></tfooter></table>里面,但是却无法控制的,除非修改 /vendor/里面的类, GridView (D:\website\yii2\basic\vendor\yiisoft\yii2\grid\GridView.php) 方法 renderTableFooter,如何生成 <tr><td colspan="30"><input type="submit" value="批量删除"></td></tr>

<code># 文件 D:\website\yii2\basic\vendor\yiisoft\yii2\grid\GridView.php
   /**
     * Renders the table footer.
     * @return string the rendering result.
     */
    public function renderTableFooter()
    {
        $cells = [];
        foreach ($this->columns as $column) {
            /* @var $column Column */
            $cells[] = $column->renderFooterCell();
        }
        $content = Html::tag('tr', implode('', $cells), $this->footerRowOptions);
        if ($this->filterPosition == self::FILTER_POS_FOOTER) {
            $content .= $this->renderFilters();
        }

        return "<tfoot>\n" . $content . "\n</tfoot>";
    }
</code>
Copy after login
Copy after login

foreach 这个里面已经无法控制 colunms 了,无法生成 <tfooter><tr><td colspan="30"></td></tr></tfooter>,yii2如何使用批量功能?

回复内容:

使用yii2 生成管理列表,有 CheckboxColumns::className()这个可以生成复选框,但这个“批量提交”的按钮是放到哪里?我想把批量删除的按钮放在GridView 生成的<table><tfooter></tfooter></table>里面,但是却无法控制的,除非修改 /vendor/里面的类, GridView (D:\website\yii2\basic\vendor\yiisoft\yii2\grid\GridView.php) 方法 renderTableFooter,如何生成 <tr><td colspan="30"><input type="submit" value="批量删除"></td></tr>

<code># 文件 D:\website\yii2\basic\vendor\yiisoft\yii2\grid\GridView.php
   /**
     * Renders the table footer.
     * @return string the rendering result.
     */
    public function renderTableFooter()
    {
        $cells = [];
        foreach ($this->columns as $column) {
            /* @var $column Column */
            $cells[] = $column->renderFooterCell();
        }
        $content = Html::tag('tr', implode('', $cells), $this->footerRowOptions);
        if ($this->filterPosition == self::FILTER_POS_FOOTER) {
            $content .= $this->renderFilters();
        }

        return "<tfoot>\n" . $content . "\n</tfoot>";
    }
</code>
Copy after login
Copy after login

foreach 这个里面已经无法控制 colunms 了,无法生成 <tfooter><tr><td colspan="30"></td></tr></tfooter>,yii2如何使用批量功能?

'showFooter'=>true,然后'footer'=>'批量删除'。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template