【问题标题】:Remove Dollar sign from Column value(Indian Currency) Yii2 kartik gridview从列值(印度货币)Yii2 kartik gridview 中删除美元符号
【发布时间】:2016-12-13 09:47:48
【问题描述】:

下面是我在 Yii2 中使用 Kartik Gridview 小部件的索引页面的快照;

下面是相同的gridview代码。

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    //'filterModel' => $searchModel,

    'columns' => [
        [
            'class' => 'kartik\grid\SerialColumn',
            'contentOptions' => ['class' => 'kartik-sheet-style'],
            'headerOptions' => ['class' => 'kartik-sheet-style'],
        ],
        //'line_id',
         'metal_name',
         'item',
         'unit_name',
         'weight',
        ['attribute' => 'quantity',
            'pageSummary' =>(true),
            'value' => function ($model) {
                if($model){
                    return  $model->quantity;
                }
            }],
         'rate_per_gram',
         'making_charges',
        [
            'attribute' => 'total',
            'format'=>'currency',
            'pageSummary' =>(true),
            'value' => function ($model) {
                            if($model){
                                return $model->total;
                            }
                        }
        ],
        ['class' => 'kartik\grid\ActionColumn'],
    ],
    'responsive'=>true,
    'hover'=>true,
    'export'=>false,
    'showPageSummary' => true,
]); ?>
  1. 我已经尝试了很多方法来获得 2 位小数的纯数字格式,但我可以成功。

  2. 如何使用印度货币格式化我的 Total 列,即。 卢比。 35670.00 还是35670.00

【问题讨论】:

    标签: yii2 yii2-advanced-app yii-extensions


    【解决方案1】:

    一种方法是直接设置货币:

    [
        'attribute' => 'total',
        'format' => ['currency', 'INR'],
        'pageSummary' => true,
    ],
    

    PS。除非您想在某些情况下将其替换为其他内容,否则您无需设置 value 键。

    【讨论】:

    • 非常感谢比兹利!你总是节省我的时间。
    • 另一种没有货币的格式,我看到了 kartik gridview 的源代码是 'format'=>['decimal', 2],
    猜你喜欢
    • 1970-01-01
    • 2016-10-24
    • 1970-01-01
    • 2011-11-26
    • 1970-01-01
    • 1970-01-01
    • 2018-03-29
    • 1970-01-01
    相关资源
    最近更新 更多