- Home
- Forum
- ASP.NET MVC - EJ 2
- EJ2 - MVC - Grid - Globalization "pt-Br"
EJ2 - MVC - Grid - Globalization "pt-Br"
Hi!
Sorry if this is a very basic question, but I did some research and could not implement the grid property "locale" to "pt-BR".
At this point I basically followed the procedures described in the "getting-started" session in my MVC5 project.
There is some step by step to implement the locality of the grid or the globalization of all the controls for the language "pt-BR" (Brazilian Portuguese)?
Thank you!
SIGN IN To post a reply.
9 Replies
MS
Madhu Sudhanan P
Syncfusion Team
December 19, 2018 10:19 AM UTC
Hi Guia,
Thanks for contacting Syncfusion support.
As per your requirement we have created a sample for your reference. In the below sample, we have applied pt-BR locale for Grid using SetCulture method and load the corresponding cldr-data. Please refer the below code example and sample for more information.
[Views/Home/index.cshtml]
|
<script>
ej.base.L10n.load({
'pt-BR': {
'grid': {
EmptyRecord: 'Nenhum registro para exibir',
True: 'real',
False: 'falso',
. . . . .
},
'pager': {
currentPageInfo: '{0} de {1} páginas',
totalItemsInfo: '(Elementos {0})',
. . . . .
}
}
});
</script>
<div>
@Html.EJS().Grid("Grid").Locale("pt-BR").DataSource((IEnumerable<object>)ViewBag.datasource).Columns(col =>
{
col.Field("OrderID").IsPrimaryKey(true).HeaderText("Name").Width("160").Add();
. . . . .
col.Field("Verified").HeaderText("Verified").Width("150").Add();
}).AllowPaging().Render()
</div> |
[Views/Shared/_Layout.cshtml]
|
<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('pt-BR');
};
for (var prop = 0; prop < files.length; prop++) {
loadCulture(prop);
}
}
document.addEventListener('DOMContentLoaded', function () {
// load corresponding cldr-data
loadCultureFiles('pt');
});
</script> |
Sample : http://www.syncfusion.com/downloads/support/directtrac/general/ze/Ej2-globalculture-pt-BR-1166127633
Help documentation:
Regards,
Madhu Sudhanan P
GU
Guia
December 20, 2018 12:39 PM UTC
Hi Madhu! How are you?

The grid and the pager are work great. But i need translate the validation message too. Can you give me a hint about how i do this??
Thanks!
Guilherme
MS
Madhu Sudhanan P
Syncfusion Team
December 21, 2018 05:49 AM UTC
Hi Guia,
Thanks for the update.
We can override default form validator messages using the actionComplete event as follows.
|
@(Html.EJS().Grid("Grid").ActionComplete("actionComplete")
...
.Render())
<script>
function actionComplete(e) {
if (e.requestType == 'add' || e.requestType == 'beginEdit') {
var formValidator = e.form.ej2_instances[0];
ej.base.extend(formValidator.defaultMessages, {
required: "Este campo é obrigatório"
});
}
}
</script>
|
For default rules and their messages please go through the below link.
Regards,
Madhu Sudhanan P
GU
Guia
December 27, 2018 11:33 AM UTC
Hi Madhu!

Thanks for the answer.
Maybe i did something wrong, but the code does not work. Please, see image below:
Other important information is that i'm using "double click editing" and "edit batch" funcionalities so i guess the "actionComplete" function is not called when a begin edit.
When i debug in browser i can see this function is called on paging, filter...
Regards,
Guilherme
GU
Guia
December 27, 2018 01:10 PM UTC
Hi Madhu,


i did some changes and now its ok.
This is the recommended solution?
Thanks for your atention
Guilherme
GU
Guia
December 27, 2018 01:23 PM UTC
Hi!


Other solution is use the "locale" property as below:
Regards,
Guilherme
MS
Madhu Sudhanan P
Syncfusion Team
December 31, 2018 08:36 AM UTC
Hi Guilherme,
We are glad that you have achieved your requirement. Setting locale string using ej.base.L10n.load in the recommended way for localize the form validator messages.
Regards,
Madhu Sudhanan P
GU
Guia
January 2, 2019 04:46 PM UTC
Hi Madhu!
Thank you for the support! I'm learning a lot of things with you!.
Regards,
Guilherme
MS
Madhu Sudhanan P
Syncfusion Team
January 3, 2019 04:42 AM UTC
Hi Guilherme,
Thanks for the update. Please get back to us if you require further assistance.
Regards,
Madhu
SIGN IN To post a reply.
- 9 Replies
- 2 Participants
-
GU Guia
- Dec 18, 2018 04:39 PM UTC
- Jan 3, 2019 04:42 AM UTC