- Home
- Forum
- ASP.NET Core - EJ 2
- After changing locale (currency code) aggregate row values ramain in old currency format
After changing locale (currency code) aggregate row values ramain in old currency format
I have a grid definition
Attachment: Pictures_139c708f.zip
<ejs-grid id="Grid" allowPaging="true" allowResizing="true" enablePersistence="true">
<e-grid-aggregates>
<e-grid-aggregate>
<e-aggregate-columns>
<e-aggregate-column field="debit" type="Sum" format="C2"></e-aggregate-column>
<e-aggregate-column field="credit" type="Sum" format="C2"></e-aggregate-column>
</e-aggregate-columns>
</e-grid-aggregate>
</e-grid-aggregates>
<e-grid-pagesettings pageSizes="true"></e-grid-pagesettings>
<e-grid-columns>
<e-grid-column field="transDate" headerText="TransDate" textAlign="Right" width="50" type="date" format="dd/MM/yyyy"></e-grid-column>
<e-grid-column field="docSeriesCode" headerText="DocSeriesCode" width="60"></e-grid-column>
<e-grid-column field="refCode" headerText="RefCode" width="60" textAlign="Right"></e-grid-column>
<e-grid-column field="companyCode" headerText="CompanyCode" width="60"></e-grid-column>
<e-grid-column field="debit" headerText="Debit" width="50" type="number" textAlign="Right" format="C2"></e-grid-column>
<e-grid-column field="credit" headerText="Credit" width="50" type="number" textAlign="Right" format="C2"></e-grid-column>
<e-grid-column field="runningTotal" headerText="RunningTotal" type="number" width="50" textAlign="Right" format="C2"></e-grid-column>
</e-grid-columns>
</ejs-grid>
I have a combo box with currenies and the user selects a display currency
When the grid shows everything is ok
When I change currency then rows change currency code correctly but aggregate row remains in previous currency code
This is currency change code
const setCurrency = (currencyId, currencyCode,currencyLocale) => {
const $selectedCurrency = $('.selected-currency-text');
$selectedCurrency.data('currencyid', currencyId);
$selectedCurrency.data('currencycode', currencyCode);
$selectedCurrency.data('currencylocale', currencyLocale);
$selectedCurrency.text(currencyCode);
try {
console.log(currencyCode);
console.log(currentCulture);
let cCulture = currencyLocale;
let cBaseCulture=cCulture;
if (cCulture.length>2){
cBaseCulture=cCulture.substr(0,2);
}
loadCultureFiles(cBaseCulture);
loadEj2Translation(cBaseCulture);
ej.base.setCulture(cBaseCulture);
ej.base.setCurrencyCode(currencyCode);
formatterCurrency = new Intl.NumberFormat(cCulture,
{
style: 'currency',
currency: currencyCode,
minimumFractionDigits: 2
});
} catch (e) {
console.log('Problem setting currency formatter');
}
};const loadCultureFiles=(name) =>{
let files = ['ca-gregorian.json', 'numbers.json', 'timeZoneNames.json', 'currencies.json'];
if (name === 'ar') {
files.push('numberingSystems.json');
}
let loader = ej.base.loadCldr;
let loadCulture = function (prop) {
let val
let ajax;
if (name === 'ar' && prop === files.length - 1) {
ajax = new ej.base.Ajax(location.origin + location.pathname + '/../../../lib/cldr-data/supplemental/' + files[prop], 'GET', false);
} else {
ajax = new ej.base.Ajax(location.origin + location.pathname + '/../../../lib/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);
}
};const loadEj2Translation=(name)=>{
let path = `/lib/ej2translations/${name}.json`;
let ajax = new ej.base.Ajax(path, 'GET', false); //load the name json culture file
ajax.send().then((e) => {
var culture = JSON.parse(e);
ej.base.L10n.load(
culture
);
});
};I am attaching two imagesfirst is initial show in eurossecond image is after user changes currency to bulgarian lev
Attachment: Pictures_139c708f.zip
SIGN IN To post a reply.
6 Replies
AG
Ajith Govarthan
Syncfusion Team
May 11, 2020 11:35 AM UTC
Hi George,
Greetings from Syncfusion.
Based on your requirement we have prepared sample and in that sample we have dynamically changed the culture using the ComboBox component & we also changed the currency format in the aggregates.
For your convenience we have attached the sample so please refer the sample for your reference.
Code Snippet:
|
Index.cshtml
function onChange(args) {
// debugger;
var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
if (args.value === "en-US") {
grid.locale = "en-US";
}
if (args.value === "Ar") {
setCulture();
grid.locale = "ar";
}
}
function loadCultureFiles(name) {
var files = ['ca-gregorian.json', 'numbers.json', 'currencies.json', 'timeZoneNames.json'];
if (name === 'ar') {
files.push('numberingSystems.json');
}
var loader = ej.base.loadCldr;
var loadCulture = function (prop) {
var val, ajax;
if (name === 'ar' && prop === files.length - 1) {
ajax = new ej.base.Ajax(location.origin + location.pathname + '/../../js/cldr-data/supplemental/' + files[prop], 'GET', false);
}
else {
ajax = new ej.base.Ajax(location.origin + location.pathname + '/../../js/cldr-data/main/' + name + '/' + files[prop], 'GET', false);
}
ajax.onSuccess = function (value) {
val = value;
loader(JSON.parse(val));
};
ajax.send();
};
for (var prop = 0; prop < files.length; prop++) {
loadCulture(prop);
}
} |
Regards,
Ajith G.
GK
George Koukoudis
May 11, 2020 01:33 PM UTC
Thank you for your reply.
But this doesn't solve my problem.
I will explain again the workflow of the grid.
When the grid loads I set the currency to the last saved currency.
The grid shows and everything is OK
When the user selects another currency then I make a call to my webapi and get the new data
I assign the new data to the grid
var grid = document.getElementById("Grid").ej2_instances[0];
grid.dataSource =result.value;
and change the currency and translation on the grid
loadCultureFiles(cBaseCulture);
loadEj2Translation(cBaseCulture);
ej.base.setCulture(cBaseCulture);
ej.base.setCurrencyCode(currencyCode);
The full code is shown in previous post
The result is that the data lines are formatted correctly BUT the aggregated line changes the value but not the format .
It formats the changed value with the previous currency symbol.
AG
Ajith Govarthan
Syncfusion Team
May 14, 2020 03:46 AM UTC
Hi George,
Sorry for the inconveniences.
Currently We are working on your requirement and will update you on or before 15th May 2020.
Regards,
Ajith G
AG
Ajith Govarthan
Syncfusion Team
May 15, 2020 03:18 PM UTC
Hi George,
Thanks for the patience.
We have reproduced the reported issue that is “changed culture currency is not applied to aggregates”. Currently we are checking the reproduced issue with our end and we will update further details regarding the issue on 18th May 2020.
Until then we appreciate your patience.
Regards,
Ajith G.
AG
Ajith Govarthan
Syncfusion Team
May 18, 2020 02:46 PM UTC
Hi George,
Sorry for the inconveniences.
Currently we are validating the reported issue at our end and will update you on 19th May 2020.
Regards,
Ajith G
AG
Ajith Govarthan
Syncfusion Team
May 20, 2020 02:42 PM UTC
Hi George,
Thanks for the patience.
We are able to reproduce the issue at our end. So we have considered this “Need update currency format for aggregate rows when change locale dynamically” as a defect and logged a report for the same. We will include the defect fix in our upcoming June 3, 2020 patch release.
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.
Feedback link : https://www.syncfusion.com/feedback/14536/need-update-currency-format-for-aggregate-rows-when-change-locale-dynamically
Regards,
Ajith G.
SIGN IN To post a reply.
- 6 Replies
- 2 Participants
-
GK George Koukoudis
- May 9, 2020 06:27 PM UTC
- May 20, 2020 02:42 PM UTC