如何在mvcgrid.net中使用资源文件.resx获取翻译后的列标题文本?
发布于 2017-06-10 06:11:13
这里有一个本地化的例子: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,但我认为应该是相同的想法。
https://stackoverflow.com/questions/34223980
复制相似问题