【发布时间】:2018-10-12 23:20:25
【问题描述】:
我正在使用 NonFactors Grid.Mvc (http://mvc-grid.azurewebsites.net/),如果您在 http://mvc-grid.azurewebsites.net/Grid/SourceUrl 上看到示例,我发现此网格存在限制
上例中的代码为(粗线包含无法通过lambda表达式的限制):
@model IEnumerable<Person>
@(Html
.Grid(Model)
.Build(columns =>
{
columns.Add(model => model.Name).Titled("Name");
columns.Add(model => model.Surname).Titled("Surname");
columns.Add(model => model.MaritalStatus).Titled("Marital status");
columns.Add(model => model.Age).Titled("Age");
columns.Add(model => model.Birthday).Titled("Birth date").Formatted("{0:d}");
columns.Add(model => model.IsWorking).Titled("Employed");
})
.WithSourceUrl(Url.Action("SourceUrl", "Grid"))
.Empty("No data found")
.Pageable(pager =>
{
pager.PagesToDisplay = 3;
pager.RowsPerPage = 2;
})
.Filterable()
.Sortable()
)
我想用.WithSourceUrl(Url.Action("SourceUrl", "Grid", new {m => m.personId}))替换.WithSourceUrl(Url.Action("SourceUrl", "Grid"))
我做了研究来创建这样的方法
public MvcHtmlString WithSourceUrlFor<TValue>(Expression<Func<T, TValue>> expression)
{
var MvcHtmlString = ExpressionHelper.GetExpressionText(expression);
return MvcHtmlString;
}
但我无法将 lamda 表达式转换为 MvcHtmlString 并且卡住了。
请帮帮我。
谢谢
【问题讨论】:
-
@marc_s 你能帮帮我吗?我被困住了,它真的成为我的噩梦。谢谢
标签: asp.net-mvc linq html-helper nonfactors-mvc-grid