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

Format value

Thread ID:

Created:

Updated:

Platform:

Replies:

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

Hi, 

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. 
 
[component.ts] 
@Component({ 
    selector: 'control-content', 
    template: '  <ejs-grid [dataSource]='data' height='350'> 
        <e-columns> 
            <e-column field='OrderID' headerText='Order ID' [valueAccessor]='valueAccess' width='120' textAlign='Right'></e-column> 
             .   .   . 
        </e-columns> 
    </ejs-grid>' 
}) 
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; 
    } 
    format(format,value){ 
       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. 
 
Regards, 
Pavithra S. 


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

;