Hi
I load the cldr-data files on each page through _Master layout, this works for the grids, in fact the decimal values contain the comma as a decimal point, as expected by the Italian culture, but when I open the grid editing dialog, the value appears with the period and not with the comma, also if I insert a number with the comma , the decimal part is not considered.
Example: 10,50 return 10.00 / 10.50 return 10.50
<script>
ej.base.L10n.load({
'it': {
'grid': {
'EmptyRecord': 'Keine Aufzeichnungen angezeigt',
'GroupDropArea': 'Ziehen Sie einen Spaltenkopf hier, um die Gruppe ihre Spalte',
'UnGroup': 'Klicken Sie hier, um die Gruppierung aufheben',
'EmptyDataSourceError': 'DataSource darf bei der Erstauslastung nicht leer sein, da Spalten aus der dataSource im AutoGenerate Spaltenraster',
'Item': 'Artikel',
'Items': 'Artikel'
},
'pager': {
'currentPageInfo': '{0} von {1} Seiten',
'totalItemsInfo': '({0} Beiträge)',
'firstPageTooltip': 'Zur ersten Seite',
'lastPageTooltip': 'Zur letzten Seite',
'nextPageTooltip': 'Zur nächsten Seite',
'previousPageTooltip': 'Zurück zur letzten Seit',
'nextPagerTooltip': 'Zum nächsten Pager',
'previousPagerTooltip': 'Zum vorherigen Pager'
}
}
});
</script>
<div>
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.datasource).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).ValidationRules(new { required = "true" }).Add();
col.Field("CustomerID").HeaderText("Customer Name").Width("150").ValidationRules(new { required = "true", minLength = 3 }).Add();
col.Field("Freight").HeaderText("Freight").Width("120").EditType("numericedit").Format("N2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("ShipName").HeaderText("Ship Name").Width("150").Add();
col.Field("ShipCountry").HeaderText("Ship Country").EditType("dropdownedit").Width("150").Add();
}).AllowPaging().EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render()
</div>
|
<div class="container body-content">
@RenderBody()
</div>
<script>
function loadCultureFiles(name) {
var files = ['numbers.json', 'timeZoneNames.json', 'currencies.json', 'ca-gregorian.json'];
var loadCulture = function (prop) {
var val, ajax;
ajax = new ej.base.Ajax(location.origin + '/../../scripts/cldr-data/main/' + name + '/' + files[prop], 'GET', true);
ajax.onSuccess = function (value) {
val = value;
ej.base.loadCldr(JSON.parse(val));
};
ajax.send();
ej.base.setCulture('it');
ej.base.setCurrencyCode('EUR')
};
for (var prop = 0; prop < files.length; prop++) {
loadCulture(prop);
}
}
document.addEventListener('DOMContentLoaded', function () {
loadCultureFiles('it');
});
</script>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
@Html.EJS().ScriptManager()
</body>
</html> |
Hi Manivel,
thank you for support.
Actually I tried to make an example with the suggestions you gave me, and it worked, but if the same code I insert it into my project the problem occurs.
I'm afraid the responsibility lies with the database returning a value with the comma instead for the decimal type.
I don't know where to fix the problem.
Hi Manivel,
I create a new sample, which I attach to you and in this case the problem occurs.
[_UP.cshtml]
. . .
<div class="e-float-input e-control-wrapper">
// here we have rendered the numerictextbox for the Value column while editing
@Html.EJS().NumericTextBox("Value").Value(Model.Value).Format("C2").Placeholder("Value").FloatLabelType(Syncfusion.EJ2.Inputs.FloatLabelType.Always).Render()
</div>
. . .
@Html.EJS().ScriptManager() |
[_PP.cshtml]
. . .
<div>
// here we have rendered the numerictextbox for the Value column while adding
@Html.EJS().NumericTextBox("Value").Format("C2").Placeholder("Value").Render()
</div>
. . . |
Hi Manivel,
unfortunately the proposed solution does not work, as you can see from the images
function onActionBegin(args) {
if (args.requestType === "save") {
var listInstance = args.form.querySelector("#CountyId").ej2_instances[0];
args.data["CountyId"] = listInstance.value;
console.log(args.data);
}
|
Hi Manivel,
the example attached to your previous answer, works fine, but the same code inserted in my project returns a different result as you can see in the images.
I have the same problem. Could you resolve it?
Thanks
The same problem to me with Asp.Net Core, the grid display correctly the decimal numbers.
<e-grid-column field="Prezzo" headerText="Prezzo" validationRules="@(new { required=true})" format="c2" width="150" textAlign="Right"></e-grid-column>
When I start editing in dialog the decimal is always correct.
<ejs-numerictextbox ejs-for="Prezzo" format="c2" validateDecimalOnType="true" min="0" decimals="3" blur="changeInput" change="changeInput"></ejs-numerictextbox>
When I save and close the dialog, the grid rounds all decimals. I tried with the "it" and the default "en" localization but the problem is the same.
Do you have a solution?
Thanks in advance.
Regards,
Antonio
Hi Customer,
Based on your query we have prepared a sample and tried to reproduce your reported problem at our end, but it was unsuccessful. For your reference, please refer the below working sample and video demo,
Sample:
Video demo:
If you still face any issue, please share the below details that would be helpful for us to provide better solution.
1) Share your complete Grid rendering code.
2) Share your Syncfusion package version.
3) If possible, share any issue reproducible sample or try to reproduce the issue with our above attached sample.
Hi Ravi,
I tried with Syncfusion.EJ2.AspNet.Core 21.2.10 and 22.1.34.
Here is my rendering code of Grid
<ejs-grid id="Grid"
dataSource="@Model.Articoli"
toolbar="toolbarItems"
actionComplete="actionComplete"
actionFailure="actionFailure"
allowResizing="true"
allowSelection="true">
<e-grid-editSettings allowAdding="true" allowEditing="true" allowDeleting="true" showDeleteConfirmDialog="true" mode="Dialog" template="#dialogTpl"></e-grid-editSettings>
<e-grid-sortsettings columns="sortCols"></e-grid-sortsettings>
<e-grid-columns>
<e-grid-column field="Id" isPrimaryKey="true" visible="false"></e-grid-column>
<e-grid-column field="Matricola" headerText="Matricola" width="220"></e-grid-column>
<e-grid-column field="Classe" headerText="Classe" width="80"></e-grid-column>
<e-grid-column field="Descrizione" headerText="Descrizione" width="auto"></e-grid-column>
<e-grid-column field="Um" headerText="U.M." width="50" textAlign="Center"></e-grid-column>
<e-grid-column field="Quantità" headerText="Q.tà" validationRules="@(new { required=true})" format="n1" type="number" width="150" textAlign="Center"></e-grid-column>
<e-grid-column field="Prezzo" headerText="Prezzo" validationRules="@(new { required=true})" format="c2" type="number" width="150" textAlign="Right"></e-grid-column>
<e-grid-column field="Totale" headerText="Imponibile" format="c2" type="number" width="150" textAlign="Right"></e-grid-column>
<e-grid-column field="RifSketch" headerText="Rif. Sketch" width="150"></e-grid-column>
<e-grid-column headerText="Azioni" width="120" commands="commands" textAlign="Center"></e-grid-column>
</e-grid-columns>
</ejs-grid>
This is my model
public class OffertaArticoloViewModel
{
public int Id { get; set; }
[StringLength(3)]
public string Classe { get; set; }
[StringLength(50)]
public string Matricola { get; set; }
[StringLength(2000)]
public string Descrizione { get; set; }
public int OpzioneCodice { get; set; }
public decimal PrezzoAcc { get; set; }
public decimal Prezzo { get; set; }
public decimal Sconto { get; set; }
public decimal PrezzoScontato { get; set; }
public decimal Quantità { get; set; }
public decimal TotaleParziale { get; set; }
public decimal Totale { get; set; }
[StringLength(3)]
public string Um { get; set; }
public string Note { get; set; }
}
This is the partial edit dialog template code
<div class="row">
<div class="col-2">
<label asp-for="Um" class="form-label">U.M.</label>
<ejs-textbox ejs-for="Um" type="text" class="form-control" />
</div>
<div class="col">
<label asp-for="Quantità" class="form-label">Quantità</label>
<ejs-numerictextbox ejs-for="Quantità" validateDecimalOnType="true" min="0" decimals="3" blur="changeInput" change="changeInput"></ejs-numerictextbox>
</div>
<div class="col">
<label asp-for="Prezzo" class="form-label">Prezzo</label>
<ejs-numerictextbox ejs-for="Prezzo" format="c2" validateDecimalOnType="true" min="0" decimals="3" blur="changeInput" change="changeInput"></ejs-numerictextbox>
</div>
<div class="col">
<label asp-for="Totale" class="form-label">Imponibile</label>
<ejs-numerictextbox ejs-for="Totale" format="c2" showSpinButton="false" readonly></ejs-numerictextbox>
</div>
</div>
Antonio,
We have checked your shared code examples and we could see that you are not shared the code part about definitions of locale. In our previously shared sample, we have loaded the culture files from the cldr files and set the culture and currency code. Please refer the below code example and documentation for more information.
<script> function loadCultureFiles(name) { var files = ['numbers.json', 'timeZoneNames.json', 'currencies.json', 'ca-gregorian.json']; var loadCulture = function (prop) { var val, ajax; ajax = new ej.base.Ajax(location.origin + '/../../scripts/cldr-data/main/' + name + '/' + files[prop], 'GET', true); ajax.onSuccess = function (value) { val = value; ej.base.loadCldr(JSON.parse(val)); }; ajax.send(); ej.base.setCulture('it'); ej.base.setCurrencyCode('EUR') }; for (var prop = 0; prop < files.length; prop++) { loadCulture(prop); } } document.addEventListener('DOMContentLoaded', function () { loadCultureFiles('it'); }); </script>
|
Also, we have checked the response which was return from the server, and it was also returned the proper value at our end. So please ensure once what values are returning from the server after your save action. Please refer the below video demo for more information.
Sample:
Video demo:
Documentation: https://ej2.syncfusion.com/aspnetcore/documentation/common/internationalization
Note: We are not able to run your application at our end, because your shared sample does not contain the EditPartial file.
So, if you still face the issue, please share the runnable application that would be helpful for us to validate or try to replicate your issue in our shared sample.
Are there any updates on the issue?
I'm facing the same. Could it be IT locale vs EN server?
Stefano,
After reviewing the information you provided, we understand that you're encountering an issue with the IT locale. However, the details you provided were insufficient for us to fully address your query. To assist you, we've prepared a Grid sample using the IT culture, which worked fine on our end. Please ensure that your application follows the same approach to load the IT culture. For more information, please refer to the code example, sample and documentation provided below.
<div> @Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col => { . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
}).Locale("it").Render() </div>
<script> document.addEventListener('DOMContentLoaded', function () { loadCultureFiles('it'); });
function loadCultureFiles(name) { var files = ['numbers.json', 'timeZoneNames.json', 'currencies.json', 'ca-gregorian.json']; var loadCulture = function (prop) { var val, ajax; ajax = new ej.base.Ajax(location.origin + '/../../scripts/cldr/main/' + name + '/' + files[prop], 'GET', true); ajax.onSuccess = function (value) { val = value; ej.base.loadCldr(JSON.parse(val)); }; ajax.send(); ej.base.setCulture('it'); }; for (var prop = 0; prop < files.length; prop++) { loadCulture(prop); } } ej.base.L10n.load({ 'it': { 'grid': { "EmptyRecord": "nessun dato da visualizzare", "True": "vero", "False": "falso", "InvalidFilterMessage": "Dati filtro non validi", . . . . . . . . . . . . . . . . } } });
|
Sample:
Documentation: https://ej2.syncfusion.com/aspnetmvc/documentation/common/internationalization#loading-culture-data
Screenshot:
If you still face the issue, please share the below details that would be helpful for us to provide better solution.
1) Share your complete Grid rendering code, we would like to check how you are loading the IT culture in your application.
2) Share the issue scenario with video demonstration.
3) If possible, please try to reproduce the issue with our shared sample that would be helpful for us to provide better solution.
Hi Ravi,
The 'it' culture files are loaded correctly. I've managed to find a "solution".
I was initially binding a decimal property in my ViewModel to a NumericTextBox in my grid dialog editor. However, when posting the ViewModel data, the value was being truncated to a whole number (e.g. 1,15 => 1).
To work around this, I tried binding a string property to the numeric TextBox instead. This approach worked well for both rendering and posting. While I understand it's not an ideal solution, it does the job. (e.g. 1,15 => "1,15")
Still not sure why a number, with a locale format, cannot be edited and posted correctly on grid dialog edit, but on inline edit it works.
Ty
Stefano,
We are happy
to hear that now the IT culture is loaded correctly, and you have found the
solution at your end.
Additionally, in your query, you mentioned, "Still not sure why a number,
with a locale format, cannot be edited." Since the reported issue only
occurs in your application and works correctly on our end, the provided
information is insufficient for further validation. We need more details from
your side to investigate further.
1) Share your complete Grid code, including both client-side and server-side, so we can review your Grid initialization.
2) Share the code that shows how you are binding a decimal property in your ViewModel to a NumericTextBox.
3) Share your Syncfusion package version.
4) Share the issue scenario with video demonstration.
5) Please try to reproduce the issue using the sample we shared, following the same scenario of binding a decimal property in your ViewModel to a NumericTextBox or share any issue reproducible sample that would be helpful for us to provide better solution.