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

Number Formatting in Ej2 Pivotgrid

Hi,

i have a pivotgrid where i want to display number with group separator with 2 numbers. For example: I want display the number in these format like 12,82,500.50. So can you please tell me how to do these. I have use format:'n2'.

4 Replies

JP Jagadeesan Pichaimuthu Syncfusion Team June 13, 2019 07:27 AM UTC

Hi Bhavesh, 
  
You can format value fields using formatSettings. Please refer following code snippet. 
  
Code Snippet: 
var pivotGridObj = new ej.pivotview.PivotView({ 
    dataSource: { 
        values: [{ name: 'Sold'caption: 'Units Sold' }, { name:'Amount'caption: 'Sold Amount' }], 
        formatSettings: [{ name: 'Amount'format: 'N2' }], 
    } 
}); 
pivotGridObj.appendTo('#PivotView'); 
  
  
  
  
Please let us know if you need further assistance on this. 
  
Regards, 
Jagadeesan 



BP Bhavesh Patil June 13, 2019 10:57 AM UTC

With just using format n2 is not heIpfull. I want display the number Grouping in these format like 12,82,500.50.


MM Manikandan Murugesan Syncfusion Team June 14, 2019 05:49 PM UTC

Hi Bhavesh, 
 
Currently, we are analyzing your requirement. And, we will update you the details on 17th June 2019.  

Regards, 
Manikandan. 



MM Manikandan Murugesan Syncfusion Team June 17, 2019 01:31 PM UTC

Hi Bhavesh, 
  
Thanks for the patience. 
 
You can achieve your requirement by loading ‘cldr-data’ (en-IN) using AJAX. Please refer following code snippet. 
 
Code Snippet: 
<script> 
    var pivotGridObj = new ej.pivotview.PivotView({ 
        dataSource: { 
            data: pivotData, 
            expandAll: false, 
            columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }], 
            values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }], 
            rows: [{ name: 'Country' }, { name: 'Products' }], 
            formatSettings: [{ name: 'Amount', format: 'N2' }], 
            filters: [] 
        } 
    }); 
    pivotGridObj.appendTo('#PivotGrid'); 
 
    function loadCultureFiles(name) { 
        var files = ['ca-gregorian.json', 'numbers.json', 'timeZoneNames.json', 'currencies.json']; 
        var loadCulture = function (prop) { 
            var val, ajax; 
            ajax = new ej.base.Ajax(location.origin + '/../../scripts/cldr-data/main/' + name + '/' + files[prop], 'GET', false); 
            ajax.onSuccess = function (value) { 
                val = value; 
            }; 
            ajax.send(); 
            ej.base.loadCldr(JSON.parse(val)); 
            ej.base.setCulture('en-IN'); 
            ej.base.setCurrencyCode('INR'); 
        }; 
        for (var prop = 0; prop < files.length; prop++) { 
            loadCulture(prop); 
        } 
    } 
 
    document.addEventListener('DOMContentLoaded', function () { 
        loadCultureFiles('en-IN'); 
    }); 
 
</script> 
 
Please let us know if you need further assistance on this. 
 
Regards, 
Manikandan. 


Loader.
Live Chat Icon For mobile
Up arrow icon