2

如何使用资源文件 .resx 在mvcgrid.net中获取翻译的列标题文本?

4

1 回答 1

0

有一个本地化示例: http: //mvcgrid.net/demo/localization

但是我们通过配置如下的 _Grid.cshtml 视图来做到这一点:

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

并在 _Grid.cshtml 中循环遍历列:

<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>

请注意,我们在这里没有使用资源,但我们正在使用这个库:https ://github.com/RickStrahl/Westwind.Globalization但我认为它应该是相同的想法。

于 2017-06-09T22:11:13.023 回答