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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Format value

Thread ID:





143250 Mar 11,2019 05:24 PM UTC Mar 12,2019 06:07 AM UTC Angular - EJ 2 1
Tags: Grid
Benjamim Goulart Bessa
Asked On March 11, 2019 05:24 PM UTC


I have a grid that have a cell that may contains two types of formats, based in lengtn of your value.

How can I correctly set my cell format?

The formats are: when value length is 14: 00.000.000/0000-00 and when is 11: 000.000.000-00.

Pavithra Subramaniyam [Syncfusion]
Replied On March 12, 2019 06:07 AM UTC

Hi Benjamim, 
Greetings from Syncfusion, 
You can achieve your requirement by using the column.valueAccessor property of Grid component. Please refer to the below code example, documentation link and sample link for more information. 
    selector: 'control-content', 
    template: '  <ejs-grid [dataSource]='data' height='350'> 
            <e-column field='OrderID' headerText='Order ID' [valueAccessor]='valueAccess' width='120' textAlign='Right'></e-column> 
             .   .   . 
export class DefaultComponent implements OnInit { 
    public data: Object[] = []; 
    public valueAccess = (field: string, data: Object, column: Object) => {      
        return data[field].toString().length == 5 ? this.format("###0.##0#",data[field]):this.format("0000 %",data[field]); 
    ngOnInit(): void { 
        this.data = orderDetails; 
       let intl: Internationalization = new Internationalization(); 
       let nParser: Function =  intl.getNumberParser({ format:format}); 
       let val: string = intl.formatNumber(value,{format: format }) 
      return val; 
Please get back to us, if you need further assistance. 
Pavithra S. 


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

Live Chat Icon For mobile
Live Chat Icon