首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在WebGrid中访问模型数据

在WebGrid中访问模型数据
EN

Stack Overflow用户
提问于 2011-03-30 01:09:39
回答 2查看 1.5K关注 0票数 2

如何访问WebGrid中的附加子模型信息?

代码语言:javascript
复制
var personGrid = new WebGrid(source: Model.People,
        ajaxUpdateContainerId: "personGrid",
        ajaxUpdateCallback: "jQueryTableStyling",
        defaultSort: "PersonID");

@personGrid.GetHtml(
        tableStyle: "webgrid",
        headerStyle: "webgrid-header",
        footerStyle: "webgrid-footer",
        alternatingRowStyle: "zebra",
              columns: personGrid.Columns(
                   personGrid.Column("PersonID", "Person ID"),
                   personGrid.Column("Name", "Name"),
                   // This line isn't working and I'm not sure how to get it to work.
                   personGrid.Column(model => model.Career.Title) 
               )
        )
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-03-30 13:12:32

尝试:

代码语言:javascript
复制
personGrid.Column(format: @<text>@item.Career.Title</text>) 
票数 3
EN

Stack Overflow用户

发布于 2019-02-12 19:24:47

@机型列表

代码语言:javascript
复制
WebGrid grid = new WebGrid(Model, canPage: true, canSort: true, rowsPerPage: 10, ajaxUpdateContainerId: "divDataList");

<div id="divDataList">
    @grid.GetHtml(tableStyle: "table-user-information table table-bordered table-striped",
        headerStyle: "webgrid-header",
        fillEmptyRows: false,
        mode: WebGridPagerModes.All,
        firstText: "<< First",
        previousText: "< Prev",
        nextText: "Next >",
        lastText: "Last >>",
        columns: grid.Columns(
        grid.Column(header: "S No.", style: "white", format: item => item.WebGrid.Rows.IndexOf(item) + 1 + Math.Round(Convert.ToDouble(grid.TotalRowCount / grid.PageCount) / grid.RowsPerPage) * grid.RowsPerPage * grid.PageIndex),

grid.Column(columnName:"registrationNo",header:“申请号”,格式:@@item.registrationNo),grid.Column("progressReportSubject",header:“进度报告主题”),grid.Column("uploadDate",header:“上传日期”),grid.Column(columnName:"progressReportPath",header:“进度报告”,格式:@ @if (!string.IsNullOrEmpty(@item.progressReportPath)) {} else {

代码语言:javascript
复制
    }
    </text>)

        ))
</div>

}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5476267

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档