2

How to use resources files .resx to get translated column header text in mvcgrid.net ?

JPM_1
  • 21
  • 2

1 Answers1

0

There is a localisation example: http://mvcgrid.net/demo/localization

But we did this through the _Grid.cshtml view which is configured like this:

GridDefaults gridDefaults = new GridDefaults()
{
      RenderingMode = RenderingMode.Controller,
      ViewPath = "~/Views/MVCGrid/_Grid.cshtml",
      NoResultsMessage = "Sorry, no results were found"
};

and in the _Grid.cshtml on looping through the columns:

<tr>
    @foreach (var col in Model.Columns)
    {
        var thStyleAttr = !String.IsNullOrWhiteSpace(ColumnStyle(col)) ? String.Format(" style='{0}'", ColumnStyle(col)) : "";
        <th onclick='@Html.Raw(ColumnOnClick(col))' @(Html.Raw(thStyleAttr))>@DbRes.T(col.HeaderText, "Grids") @(SortImage(col))</th>
    }
</tr>

Note that we are not using resources here but we are using this lib: https://github.com/RickStrahl/Westwind.Globalization but I think it should be the same idea.

Amr Elgarhy
  • 66,568
  • 69
  • 184
  • 301