如何访问WebGrid中的附加子模型信息?
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)
)
)发布于 2011-03-30 13:12:32
尝试:
personGrid.Column(format: @<text>@item.Career.Title</text>) 发布于 2019-02-12 19:24:47
@机型列表
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 {
}
</text>)
))
</div>}
https://stackoverflow.com/questions/5476267
复制相似问题