如何在 Mvccontrib 网格模型中使用自定义列?
我正在使用 ASP.NET MVC 3 Mvccontrib 网格,如下所示:
@Html.Grid(Model).Columns(column =>
{
column.For(x => x.UserId).Named("ID");
column.For(x => x.Name);
column.Custom(@<div><img src='@item.ImageUrl' alt="@item.Name"/><a href="@item.Link">@item.Name</a></div>).Named("Name");
column.For(x => x.Score).Named("Score");
})
但现在我需要将其移至自定义网格模型中:
@Html.MvcContrib().Grid(Model).WithModel(new MyGridModel()).Sort(ViewData["sort"] as GridSortOptions).Attributes(id => "grid", style => "width: 100%;")
使用相应的网格模型:
public class MyGridModel : GridModel<MyModel>
{
public MyGridModel()
{
Column.For(x => x.UserId);
Column.For(x => x.Name);
Column.For(x => x.ImageUrl);
RenderUsing(new HtmlTableGridRenderer<MyModel>());
}
}
但是如何在网格模型中执行自定义列?
Column.Custom(???);
I am using a ASP.NET MVC 3 Mvccontrib grid like so:
@Html.Grid(Model).Columns(column =>
{
column.For(x => x.UserId).Named("ID");
column.For(x => x.Name);
column.Custom(@<div><img src='@item.ImageUrl' alt="@item.Name"/><a href="@item.Link">@item.Name</a></div>).Named("Name");
column.For(x => x.Score).Named("Score");
})
But now I need to move this into a custom grid model:
@Html.MvcContrib().Grid(Model).WithModel(new MyGridModel()).Sort(ViewData["sort"] as GridSortOptions).Attributes(id => "grid", style => "width: 100%;")
with corresponding grid model:
public class MyGridModel : GridModel<MyModel>
{
public MyGridModel()
{
Column.For(x => x.UserId);
Column.For(x => x.Name);
Column.For(x => x.ImageUrl);
RenderUsing(new HtmlTableGridRenderer<MyModel>());
}
}
But how can I do my custom column in my grid model?
Column.Custom(???);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这样:
Try like this: