JPM_1
JPM_1

Reputation: 21

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

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

Upvotes: 2

Views: 133

Answers (1)

Amr Elgarhy
Amr Elgarhy

Reputation: 68952

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.

Upvotes: 0

Related Questions