Format GridView Footer as Currency

You can use YII2’s built in formatter to format any arbitrary value you like. For example, you may want to format the footer of a grid view as currency. When specifying the cell, you can set the format of that cell. However, while you can control what will be in the footer for that column, GridView does not have a method of formatting the footer values.

Here is a simple method to format any value.

  1. $formatter = new \yii\i18n\Formatter;
  2. $formatted_value = $formatter->asCurrency($value);

Published by

Joel Bowers

Web developer since 1999. PHP, YII2, Laravel, Javascript, HTML, CSS, jQuery, Perl, Wordpress, MySQL.

Leave a Reply

Your email address will not be published. Required fields are marked *