这是我的GridView代码。我希望页脚与其列具有相同的格式。我该怎么做?谢谢!
echo GridView::widget([
'dataProvider' => $dataProvider,
'showFooter' => true,
'formatter' => ['class' => 'yii\i18n\Formatter','thousandSeparator' => ',','currencyCode' => 'PHP',],
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' =>'account_code',
'footer' =>'Total',
],
'account_name',
[
'attribute' =>'amount',
'format' => 'currency',
'footer' => Accounts::getTotal($dataProvider->models, 'amount'),
],
['class' => 'yii\grid\ActionColumn'],
],
]);
答案 0 :(得分:0)
只需添加前缀
即可 'footer' => 'PHP' . Accounts::getTotal($dataProvider->models, 'amount'),
并且对于千位分隔符,您可以使用number_format
'footer' => 'PHP' .
number_format (Accounts::getTotal($dataProvider->models, 'amount'), 2 , "." , "," )