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

Different Currency In Different Rows

Thread ID:





132928 Sep 28,2017 04:07 PM UTC Oct 3,2017 04:41 AM UTC JavaScript 3
Tags: ejGrid
Michael Palmer
Asked On September 28, 2017 04:07 PM UTC

Hi. I'm wanting to show a different currency symbol per row in my grid. In my data I have a field for currency such as "USD" or "EUR". I want to use this to localize a price column. I tried to change the column format in the queryCellInfo handler, but I think it's too late in the pipeline and it has no effect.

I am using the JavaScript API for my grid. I need to know if there is another event handler I can use to modify the cell format before the default is picked up. The default is "$" as my locale is en-US.

I appreciate any help on this. I've searched online and found no documentation or solution for this problem.

Venkatesh Ayothi Raman [Syncfusion]
Replied On September 29, 2017 12:27 PM UTC

Hi Michael, 

Thanks for contacting Syncfusion support. 

We have achieved your requirement using QueryCellInfo event in Grid without giving a currency format in Column. Please refer to the following code example and Help document for more information, 
Code example
. . . 
        .Columns(col => 
               . . .            col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Add(); 
. . . 
    function QueryCellInfo(args) { 
        if (args.column.field == "Freight" && args.data.Freight == 29.46) { 
            args.cell.innerHTML = ej.format(args.data.Freight, "C2", "en-GB");//Changing the currency format dynamically 
        if(args.column.field == "Freight" && args.data.Freight == 61.02) 
            args.cell.innerHTML = ej.format(args.data.Freight, "C2", "en-AU");//Changing the currency format dynamically 
[_Layout.html page] 
   <link rel='nofollow' href="@Url.Content("~/Content/ej/web/Default-theme/ej.widgets.all.min.css")" rel="stylesheet" /> 
    <. . .> 
    <script src="@Url.Content("~/Scripts/ej/ej.web.all.min.js")"></script> 
    <script src="@Url.Content("~/Scripts/ej/ej.unobtrusive.min.js")"></script> 
    <script src="~/Scripts/ej/cultures/ej.culture.en-AU.js"></script> 
    <script src="~/Scripts/ej/cultures/ej.culture.en-GB.js"></script> 

Note: Above code example we should give the culture name for applying the format.  

We have also prepared a sample for your convenience which can be download from following link, 

Venkatesh Ayothiraman. 

Michael Palmer
Replied On October 2, 2017 03:48 PM UTC

Thank you. It worked perfectly.

I created a mapping function to map my currencies to cultures (Ex. 'EUR' => 'de-DE'). I also found the culture definition files for the 15 currencies I needed and minified them into one JS file.

The ej.format function is great. I am now also using it outside of the grid for currency formatting on other pages.


Venkatesh Ayothi Raman [Syncfusion]
Replied On October 3, 2017 04:41 AM UTC

Hi Michael, 

Thanks for the update. 

We are very happy to hear that your requirement is achieved. 

Venkatesh Ayothiraman. 


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