0

floating point numbers need to be formatted and displayed in grid. eg 123,456,567.82. Data from backend is 123456567.82. How can this be formatted in ag grid and have other features like sorting, filter work too. i did find a link in stack overflow to use Math. floor (num). tostring and applying some regex, but that truncates decimal points and not sortable.

1
  • 1
    can you post a working example in plunker ? Commented Mar 16, 2018 at 4:08

2 Answers 2

1

<!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>

You can use currency filter for and look example may hope it will helps you

Sign up to request clarification or add additional context in comments.

Comments

0

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 }
  ];

Output

1 Comment

Can you please add some explanation to make easier for everyone to understand your answer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.