【问题标题】:asp.net MVC webgrid with grouping带分组的asp.net MVC webgrid
【发布时间】:2018-03-09 21:43:48
【问题描述】:

有人可以通过 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>
    }

【问题讨论】:

    标签: c# .net asp.net-mvc-5 webgrid


    【解决方案1】:

    你有没有尝试过这样的事情

    a=>a.GroupBy(a.username).groupBy(a.location).tolist()
    

    【讨论】:

    • 组对象列表已经准备好。我只需要使用 webgrid 的帮助
    • 能否请您提供您正在使用的 webgrid 的版本和库名称?
    • 使用 Asp.net MVC 5
    猜你喜欢
    • 2012-06-21
    • 2011-05-10
    • 2011-07-03
    • 2012-05-22
    • 2012-09-03
    • 2013-01-07
    • 2011-06-30
    • 2018-04-01
    相关资源
    最近更新 更多