This is a migrated thread and some comments may be shown as answers.

How to localize kendo grid and asp MVC

1 Answer 153 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ismael
Top achievements
Rank 1
Ismael asked on 23 Nov 2016, 10:46 PM

I just to take a look in  Grid / Localization documentation, but how I can to localize the text whose coming from my JS model? for example headers ?

We are currently working on C# MVC so we are trying to localize our page by RESX files, 

Can you give us a heads up to have an idea to do this?\

thanks in advance!

localize

1 Answer, 1 is accepted

Sort by
0
Accepted
Stephen
Top achievements
Rank 2
answered on 24 Nov 2016, 07:24 PM

I'm not exactly sure what you are referring to by your "JS model", but you can do it a couple of ways for the ViewModel you bind to the grid:

1. The grid will use the Display Attribute if available.

public class ViewModel
{
    [Display(Name = "MyFieldLabel", ResourceType = typeof(MyResources))]
    public string MyField {get; set; }
}
 
@(Html.Kendo().Grid<ViewModel>()
    .Name("myGrid")
    .Columns(cols =>
    {
        cols.Bound(x => x.MyField);
    }
)

 

2. You can use the Title() method of the column setup:

@using MyProject.Resources  @* whatever using you need to get access to MyResources *@
 
@(Html.Kendo().Grid<ViewModel>()
    .Name("myGrid")
    .Columns(cols =>
    {
        cols.Bound(x => x.MyField).Title(MyResources.MyFieldLabel);
    }
)

 

 

 

Tags
Grid
Asked by
Ismael
Top achievements
Rank 1
Answers by
Stephen
Top achievements
Rank 2
Share this question
or