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

Trying to set currency to UK Pounds

Hello, I have been trying to change the currency displayed in my grid view from '$' to '£'. Is there anyway of doing this?

1 Reply

TS Thavasianand Sankaranarayanan Syncfusion Team January 18, 2019 04:03 AM

Hi Karl, 
 
Greetings from Syncfusion. 
 
Query: I have been trying to change the currency displayed in my grid view from '$' to '£'. Is there anyway of doing this?  
 
We have validated your query and created a sample based on your requirement. For Internationalization and localization, you need to include cldr files into your application. You need to download cldr-data globally in any location by using below command. 
 
Command: 
npm install cldr-data 
 
After installing cldr-data, you can find cldr-data for all locale in this location(node_modules->cldr-data->main). You need to copy the required(or all) locale cldr-data and paste into your application folder(Scripts->cldr->main->paste copied cldr files). 
 
You need to include cldr-data into your application and refer file location in index.cshtml file like below code example. Please find the below code example and sample for your reference. 

[code example] [index.cshtml] 
<div> 
    <ejs-grid id="Grid" locale="en-GB" dataSource="ViewBag.DataSource" allowPaging="true"> 
        <e-grid-pagesettings pageCount="4" pageSize="5"></e-grid-pagesettings> 
        <e-grid-columns> 
            <e-grid-column field="OrderID" headerText="Order ID" textAlign="Right" width="120"></e-grid-column> 
            <e-grid-column field="CustomerID" headerText="Customer Name" width="150"></e-grid-column> 
            <e-grid-column field="Freight" headerText="Freight" format="C2" width="120"></e-grid-column> 
            <e-grid-column field="OrderDate" headerText="Order Date" type="date" format="yMd" width="10%"></e-grid-column> 
            <e-grid-column field="ShipCountry" headerText="Ship Country" width="150"></e-grid-column> 
        </e-grid-columns> 
    </ejs-grid> 
</div> 
 
<script> 
 
 
    function loadCultureFiles(name) { 
        ej.base.setCulture(name); 
        ej.base.setCurrencyCode('GBP'); 
        var files = ['ca-gregorian.json', 'numbers.json','currencies.json', 'timeZoneNames.json']; 
        if (name === 'en-GB') { 
            files.push('numberingSystems.json'); 
        } 
        var loader = ej.base.loadCldr; 
        var loadCulture = function (prop) { 
            var val, ajax; 
            if (name === 'en-GB' && prop === files.length - 1) { 
                ajax = new ej.base.Ajax(location.origin + '/../../scripts/cldr-data/supplemental/' + files[prop], 'GET', false); 
            } else { 
                ajax = new ej.base.Ajax(location.origin + '/../../scripts/cldr-data/main/' + name + '/' + files[prop], 'GET', false); 
            } 
            ajax.onSuccess = function (value) { 
                val = value; 
            }; 
            ajax.send(); 
             
            loader(JSON.parse(val)); 
        }; 
        for (var prop = 0; prop < files.length; prop++) { 
            loadCulture(prop); 
        } 
    } 
 
    document.addEventListener('DOMContentLoaded', function () { 
        loadCultureFiles('en-GB'); 
    }); 
</script> 

Please find the sample in below link. 


Refer the help documentation. 




Please get back to us if you need further assistance. 

Regards, 
Thavasianand S. 


Loader.
Live Chat Icon For mobile
Up arrow icon