将ui-grid网格列格式设置为货币(RC 3.0) [英] Format a ui-grid grid column as currency (RC 3.0)
本文介绍了将ui-grid网格列格式设置为货币(RC 3.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面的网格选项按预期显示数据.但是,如果我尝试格式化cellTemplate中的row.entity[col.field]
值,则不会返回任何数据.
The grid options below display the data as expected. But If I try to to format the row.entity[col.field]
value in my cellTemplate, I don't get any data returned.
代码:
$scope.gridOptions = {
enableSorting: true,
columnDefs: [
{name: 'Award Title', field: 'projectTitle', minWidth: 100 },
{name: 'Amount', field: 'awardAmount', cellTemplate: '<div>{{Number(row.entity[col.field]).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')}}
]
};
任何有关如何将列格式设置为货币的指导都将受到赞赏.
Any guidance on how to format the column as currency is appreciated.
谢谢.
推荐答案
您可以使用"currency" cellFilter格式化数据.
You can use 'currency' cellFilter to format your data.
$scope.gridOptions = {
enableSorting: true,
columnDefs: [
{name: 'Award Title', field: 'projectTitle', minWidth: 100 },
{name: 'Amount', field: 'awardAmount', cellFilter: 'currency' }}
]
};
这篇关于将ui-grid网格列格式设置为货币(RC 3.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文