mvccontrib网格剃须刀问题,列。
-
13-10-2019 - |
题
下面的代码与ASPX View Engine一起使用,我试图将其转换为剃须刀,如下所示。问题是第一列不显示。
我使用动作方法将第一列转换为链接。使用Razor IT(第一列)根本没有在页面中渲染。其余的网格很好。
可能是什么问题呢?
@{Html.Grid(Model.Orders).Attributes(style => "width: 100%;").Columns(
column => {
column.For(x => x.OrderNumber).Action(p => {
@:<td>
Html.ActionLink(
p.OrderNumber.ToString(),
"orderdetail",
"OrderUpdate",
new { id = p.OrderNumber, backUrl = Url.Action("OrderHistory", new { controller = "DataController", id = ViewData["id"] }) },
new { });
@:</td>
}).HeaderAttributes(style => "text-align:left");
column.For(x => x.OrderTimeV2).HeaderAttributes(style => "text-align:left");
column.For(x => x.Status).HeaderAttributes(style => "text-align:left");
column.For(x => x.Type).HeaderAttributes(style => "text-align:left");
}).RowStart((p, row) => { }).Render();}
解决方案
我已经离开了使用MVCCONTRIB网格,因为我们的网格没有多大意义。
无论如何,问题是该问题中的代码不会返回HTML,而是将代码直接放入响应流中。和使用Razor渲染的列的代码,该列在调用时将代码放入流中。因此,它最终在渲染网格之前将列放入流中。
它是通过不使用GRID调用的剃须刀代码来解决的。
其他提示
好吧,我让它为我工作以下
@Html.Grid(Model.Result).Columns(column => {
column.For(u => u.Name).Named("Name");
column.For(u => u.Code).Named("Code");
column.For(u => Html.ActionLink("Edit", "Edit", new { id = u.Id })).Named("Edit");
您可以执行自定义列以获取想要的东西:
@Html.Grid(Model).Columns(column => {
column.Custom(
@<div>
<em>Hello there</em>
<strong>@item.Name</strong>
</div>
).Named("Custom Column");
})
在将一些.aspx页面移植到剃须刀上时,我这样做了。
不隶属于 StackOverflow