Heim > Fragen und Antworten > Hauptteil
使用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>
。
# 文件 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>";
}
foreach 这个里面已经无法控制 colunms 了,无法生成 <tfooter><tr><td colspan="30"></td></tr></tfooter>
,yii2如何使用批量功能?