Grid Export Currency culture issue

Hi,
I have a grid with property .Locale("it-IT") and with column  col.Field(c => c.prezzo).HeaderText("Prezzo").Width("10%").Format("{0:C}").Priority(1).Add()
The display Grid is ok , in the currency column I found value like this: 45,20€ .
If I try to export ,xlsx or pdf,  by  .Mappers(map => map.ExportToExcelAction(@Url.Action("ExportToExcel")).ExportToPdfAction(@Url.Action("ExportToPdf")))
and in controller I using this method
((ExcelExport)exp).Export(gridPropert, DataSource, nameFile, ExcelVersion.Excel2010, false, false, ExportTheme.BootstrapTheme),
the file result is ok, the currency column is in Euro €

but if I customize export with an ajax call action, to display a wait dialog , in controller I have to use this method  
((ExcelExport)exp).Export(gridPropert, DataSource, nameFile, ExcelVersion.Excel2010, false, false, ExportTheme.BootstrapTheme,true, Server.MapPath("~/temp"));

and with this method , the result file is not ok, the currency column is in US Dollar  $45,20

How can I resolve this ?
Thanks

PS:my version is 15.4
 

3 Replies

VN Vignesh Natarajan Syncfusion Team April 17, 2018 05:19 PM UTC

Hi Nicola, 
 
Thanks for using Syncfusion products. 
 
We have analyzed your issue (Locale is not properly set when exporting grid through ajax post) and we have prepared a sample using your code snippet. We are able to reproduce the reported issue at our end.  
 
To resolve the issue we suggest you to insert the below highlighted line before sending the ajax post to Server 
 
  if (args.itemName.indexOf("Export") != -1) { 
            $("#Grid").ejWaitingPopup("show"); 
            var model = $.extend(true, {}, this.model); 
            var tempObj = {} 
            $.extend(tempObj, ej.Grid.Locale["en-US"], ej.Grid.Locale[model.locale]); 
            var temp = tempObj.GroupCaptionFormat; 
            var split1 = temp.indexOf("{{if"); 
            var split2 = temp.indexOf(" {{else}}"); 
            var grpText = temp.slice(split1, split2).replace("{{if count == 1 }}", ""); 
            var localeProp = { EmptyRecord: tempObj.EmptyRecord, GroupCaptionFormat: temp.slice(0, split1), GroupText: grpText, True: tempObj.True, False: tempObj.False }; 
 
            model.locale = model.locale.concat(JSON.stringify(localeProp)); 
            if (this.ignoreOnExport) { 
                for (var i = 0; i < this.ignoreOnExport.length; i++) 
                    delete model[this.ignoreOnExport[i]]; 
            } 
            $.ajax({ 
                type: "POST", 
                url: url, 
                data: { GridModel: JSON.stringify(model) },//pass the grid model  
                dataType: "json", 
                success: function (response) { 
                    $("#Grid").ejWaitingPopup("hide");                    
                }, 
                error: function (Result) { 
                    $("#Grid").ejWaitingPopup("hide");                    
                } 
            }); 
     
For your convenience we have prepared a sample which can be downloaded from below link 
 
 
Note: In above code snippet we have extended the locale grid model and perform action regarding the locale property which export the Grid in concern locale value. 
 
Please get back to us if you have any concern. 
 
Regards, 
Vignesh Natarajan   



NI Nicola April 17, 2018 05:42 PM UTC

I don't understand fine, how works the code snippet but, it works perfectly !

Thank you very much
Nicola


VN Vignesh Natarajan Syncfusion Team April 18, 2018 02:33 PM UTC

Hi Nicola, 
 
Thanks for the update.  
 
To Export Grid with its respective culture and localetext, Grid in the client-side will append a Json object with the properties like EmptyRecord, GroupCaptionFormat along with the culture value to the locale property and then submitted to server-end.  
 
But the ajax call of the Grid is not doing such actions. Hence the issue occurred.  
 
We are glad to hear that your query has been resolved by our solution. 
 
Please get back to us if have further queries. 
 
 
Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon