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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

EJ2 - MVC - Grid - Globalization "pt-Br"

Thread ID:

Created:

Updated:

Platform:

Replies:

141572 Dec 18,2018 04:39 PM UTC Jan 3,2019 04:42 AM UTC ASP.NET MVC - EJ 2 9
loading
Tags: Grid
Guia
Asked On December 18, 2018 04:47 PM UTC

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!

Madhu Sudhanan P [Syncfusion]
Replied On 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> 


Help documentation:  



Regards, 
Madhu Sudhanan P 


Guia
Replied On 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

Madhu Sudhanan P [Syncfusion]
Replied On 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 


Guia
Replied On 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

Guia
Replied On 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


Guia
Replied On December 27, 2018 01:23 PM UTC

Hi!

Other solution is use the "locale" property as below:




Regards,

Guilherme


Madhu Sudhanan P [Syncfusion]
Replied On 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 


Guia
Replied On 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

Madhu Sudhanan P [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon