我正在使用 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"))
用.WithSourceUrl(Url.Action("SourceUrl", "Grid", new {m => m.personId}))
我做了研究来创建这样的方法
public MvcHtmlString WithSourceUrlFor<TValue>(Expression<Func<T, TValue>> expression)
{
var MvcHtmlString = ExpressionHelper.GetExpressionText(expression);
return MvcHtmlString;
}
但我无法将 lamda 表达式转换为 MvcHtmlString 并且我被卡住了。
请帮我。
谢谢