[英]asp.net MVC webgrid with grouping
有人可以通過webgrid在以下視圖中幫助我嗎
username location Date
a abc 12/10/2017
a def ↑ 12/10/2017
a def 12/10/2017
a def 12/11/2016
c abc 12/10/2017
username location Date
a abc 12/10/2017
a def ↓ 12/10/2017
a def 12/11/2016
c abc 12/10/2017
我在對象列表中的用戶名/位置和日期字段中進行了分組。 但無法做出以上觀點
我正在嘗試關注
@{
var grid = new WebGrid(Model, canPage: false, rowsPerPage: 5, selectionFieldName: "selectedRow", ajaxUpdateContainerId: "gridContent");
<div id="gridContent">
@grid.GetHtml(tableStyle: "webGrid",
headerStyle: "header",
alternatingRowStyle: "alt",
selectedRowStyle: "select",
columns: grid.Columns(
grid.Column("Email", "User Name"),
grid.Column("location", "location"),
grid.Column("AccessedOn", "Date"),
grid.Column(format: (item) =>
{
if (item.count > 1)
{
WebGrid subGrid = new WebGrid(source: item.x);
return subGrid.GetHtml(tableStyle: "webGrid",
headerStyle: "header",
alternatingRowStyle: "alt",
selectedRowStyle: "select",
columns: grid.Columns(
grid.Column("Email", null),
grid.Column("location", null),
grid.Column("AccessedOn", null))
);
}
else
return null;
}
)
))
</div>
}
你嘗試過這樣的事情嗎
a=>a.GroupBy(a.username).groupBy(a.location).tolist()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.