We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Error in format currency

Thread ID:

Created:

Updated:

Platform:

Replies:

143407 Mar 19,2019 12:17 PM UTC Mar 20,2019 07:08 AM UTC Angular - EJ 2 3
loading
Tags: Grid
Fabiano Melo
Asked On March 19, 2019 12:17 PM UTC

Hello

I'm not sure how to install and configure the internationalization of syncfusion correctly. In the documentation it seems that something was missing, or I could not understand. I need to format monetary values ​​on the grid. I am in Brazil, and our standard would be $ 99,999.00, that is, the dot first and then the comma. In the American pattern it is the opposite, that is, first the comma and then the point.

I did it this way and it works, but in the US standard and with the R $ of the Brazilian currency:

this.currencyFormat = {format: 'R$ #, ## 0.00'};

<e-column field = 'ValueNF' [filter] = 'filter' headerText = 'Value NF' textAlign = 'Left' [format] = 'currencyFormat'>

But if I reverse to the example below, it gives error:

this.currencyFormat = {format: 'R$ #. ## 0,00'};

The error is as follows:

ERROR TypeError: Can not read property '1' of null
    at customNumberFormat (vendor.js: 111451)
    at Object.customFormat (vendor.js: 111428)
    at Function.push .. / node_modules/@syncfusion/ej2-base/src/intl/number-formatter.js.NumberFormat.numberFormatter (vendor.js: 111739)
    at Internationalization.push ../ node_modules/@syncfusion/ej2-base/src/internationalization.js.Internationalization.getNumberFormat (vendor.js: 110002)
    at ValueFormatter.push ../ node_modules/@syncfusion/ej2-grids/src/grid/services/value-formatter.js.ValueFormatter.getFormatFunction (vendor.js: 179951)
    at new Column (vendor.js: 171719)
    at prepareColumns (vendor.js: 169666)
    at GridComponent.push ../ node_modules/@syncfusion/ej2-grids/src/grid/base/grid.js.Grid.render (vendor.js: 166942)
    at GridComponent.push ../ node_modules/@syncfusion/ej2-base/src/component.js.Component.appendTo (vendor.js: 108016)
    at vendor.js: 100002

Madhu Sudhanan P [Syncfusion]
Replied On March 19, 2019 04:49 PM UTC

Hi Fabiano, 

Thanks for contacting Syncfusion support. 

You can format to Brazilian currency by setting the currency code as “BRL” using setCurrencyCode method and specify the column format as “C2”. 


import { setCulture, setCurrencyCode } from "@syncfusion/ej2-base"; 
setCulture("pt"); 
setCurrencyCode("BRL"); 

<e-column field = 'ValueNF' [filter] = 'filter' headerText = 'Value NF' textAlign = 'Left' format= 'C2'></e-column> 


Regards, 
Madhu Sudhanan P 


Fabiano Melo
Replied On March 19, 2019 06:54 PM UTC

Hello

I did as you told me.

I did as you told me and it is returning like this: $ 99,999.99

It should look like this: R$ 99.999,99

I tried inserting in the module and in the component itself the calls and I was not successful. Are there any packages that should be installed the most?
There is also another problem, when I try to generate a PDF from the grid, if there is an e-column that has the format parameter, it returns the error below. If you remove the format, it works!

ERROR Error: Uncaught (in promise): TypeError: format.split is not a function
TypeError: format.split is not a function ...


Madhu Sudhanan P [Syncfusion]
Replied On March 20, 2019 07:08 AM UTC

Hi Fabiano, 

Thanks for your update. 

As per your requirement we have created a sample for your reference. In the below sample, we have import corresponding culture CLDR files then load and apply locale using loadCldr, setCulture and SetCurrencyCode  method.  

Please refer the below code example and sample for more information. With the below approach the PDF export will work fine.  

<ejs-grid #grid [dataSource]='data' allowPaging='true' [allowPdfExport]='true'  [toolbar]='toolbar' (toolbarClick)='toolbarClick($event)'[allowResizing]="true"> 
  <e-columns> 
      <e-column field='OrderID' headerText='Order ID' width='120'></e-column> 
      <e-column field='Freight' headerText='Freight' type='number' width='120' format='C2'></e-column> 
  </e-columns> 
</ejs-grid> 


import * as cagregorian from "./ca-gregorian.json"; 
import * as currencies from "./currencies.json"; 
import * as numbers from "./numbers.json"; 
import * as timeZoneNames from "./timeZoneNames.json"; 
 
loadCldr(cagregorian, currencies, numbers, timeZoneNames); // load json files of pt 
setCulture('pt'); // Change the Grid culture 
setCurrencyCode("BRL"); // Change the currency code 
 
export class DefaultComponent implements OnInit { 
    public data: Object[] = []; 
    @ViewChild('grid') 
    public grid: GridComponent; 
    public toolbar; 
 
    ngOnInit(): void { 
        this.data = orderDatas; 
        this.toolbar = ['PdfExport']; 
    } 
    toolbarClick(args): void { 
        switch (args.item.text) { 
            case 'PDF Export': 
                this.grid.pdfExport(); 
                break; 
        } 
    } 
} 





Please get back to us if you need further assistance on this. 

Regards, 
Madhu Sudhanan P 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;