Angular js 中 ag 网格中的货币格式
Currency format in ag grid in Angular js
浮点数需要格式化并在网格中显示。例如 123,456,567.82。来自后端的数据是 123456567.82。这如何在 ag 网格中格式化并具有其他功能,如排序、过滤工作。我确实在堆栈溢出中找到了一个 link 来使用数学。楼层(数量)。 tostring 并应用一些正则表达式,但这会截断小数点并且不可排序。
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="costCtrl">
<p>Price = {{ price | currency }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('costCtrl', function($scope) {
$scope.price = 123456567.82;
});
</script>
<p>The currency filter formats a number to a currency format.</p>
</body>
</html>
您可以使用货币过滤器并查看示例希望对您有所帮助
</p>
<pre><code>CellRendererUSD(params: any) {
var inrFormat = new Intl.NumberFormat('en-US', {
minimumFractionDigits: 2
});
return inrFormat.format(params.value);
}
columnDefs = [
{ headerName: 'A/c No', field: 'accountNo', width: 100 },
{ headerName: 'A/c Name', field: 'accountName' },
{ headerName: 'NAV', field: 'nav', cellRenderer: this.CellRendererUSD }
];
rowData = [
{ accountNo: '4', accountName: 'Janhavee', nav: 10000.49 },
{ accountNo: '5', accountName: 'Vignesh', nav: 100000.50 },
{ accountNo: '6', accountName: 'Upesh', nav: 1000000.51 }
];
浮点数需要格式化并在网格中显示。例如 123,456,567.82。来自后端的数据是 123456567.82。这如何在 ag 网格中格式化并具有其他功能,如排序、过滤工作。我确实在堆栈溢出中找到了一个 link 来使用数学。楼层(数量)。 tostring 并应用一些正则表达式,但这会截断小数点并且不可排序。
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="costCtrl">
<p>Price = {{ price | currency }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('costCtrl', function($scope) {
$scope.price = 123456567.82;
});
</script>
<p>The currency filter formats a number to a currency format.</p>
</body>
</html>
您可以使用货币过滤器并查看示例希望对您有所帮助
</p>
<pre><code>CellRendererUSD(params: any) {
var inrFormat = new Intl.NumberFormat('en-US', {
minimumFractionDigits: 2
});
return inrFormat.format(params.value);
}
columnDefs = [
{ headerName: 'A/c No', field: 'accountNo', width: 100 },
{ headerName: 'A/c Name', field: 'accountName' },
{ headerName: 'NAV', field: 'nav', cellRenderer: this.CellRendererUSD }
];
rowData = [
{ accountNo: '4', accountName: 'Janhavee', nav: 10000.49 },
{ accountNo: '5', accountName: 'Vignesh', nav: 100000.50 },
{ accountNo: '6', accountName: 'Upesh', nav: 1000000.51 }
];