Column command localization in grid dont work

2 posts, 0 answers
  1. Michel
    Michel avatar
    44 posts
    Member since:
    Sep 2011

    Posted 29 Jun 2016 Link to this post

    I use UI for ASP.NET MVC Q2 2016.

    I cannot figure out how to localize the edit and destroy button in the column command of my grid.

    My app is using core rc2

    I have include the localization feature using resource.

    The default culture is en-US as stated in startup.cs

        options.DefaultRequestCulture = new RequestCulture(culture: "en-US", uiCulture: "en-US");

    In the Model I manage the localization with resources file "...en-US.resx"

        public class TA_ACCESSORY_ACC

        [MaxLength(ApplicationDbOperation.DM_SHORTTEXT, ErrorMessage = "idsMaxError")]
        [Display(ResourceType = typeof(ApplicationResources),Name = "idsName")]
        public string NAME_ACC { get; set; }


    The column of the grid are well translated from french to English but the button command still remain in french.

    Any help will be very appreciated.


  2. Michel
    Michel avatar
    44 posts
    Member since:
    Sep 2011

    Posted 29 Jun 2016 in reply to Michel Link to this post

    It is not so difficult when you have found.

    In Startup.cs

       // Add the localization services to the services container
       services.AddLocalization(options => options.ResourcesPath = "Resources");

    In Solution explorer
      Add a folder "Resources", add a subfolder in it "Views" add a subfolder in it "MyModel"
      In this folder add a resource file with the name of the cshtml file containing the grid you want to localize "" for french localization of index.cshtml view of the MyModel class and include the string you want to translate :
        <data name="idsName" xml:space="preserve">

    In the index.cshtml view file add these lines
      @using Microsoft.AspNetCore.Mvc.Localization
      @inject IViewLocalizer Localizer

          .Columns(columns =>
            columns.Bound(model => model.MyField);
            columns.Command(commands =>
       .Editable(editable => editable.Mode(GridEditMode.PopUp))
       .DataSource(dataSource => dataSource

Back to Top