我实现了一个嵌套Webgrid,其中引用了两个表Master Table和Detail Table。我已经将明细表设为列表类型。 就像在数据库中一样,我在某些列中使用标志1或0。在我的明细表WebGrid中,我需要输出1为“是”,输出为0为“否”。但是我无法实现与声明为列表类型对象相同的输出。
@webGrid.GetHtml(
htmlAttributes: new { @id = "WebGrid", @class = "Grid" },
columns: webGrid.Columns(
webGrid.Column(null, null, format: @<text><img src="~/Images/plus.png" /><div style="display:none"></div></text>),
webGrid.Column(header: "Spare Requisition Date", format: (item) => string.Format("{0:dd-MM-yyyy}", item.objSpareRequisition.DATECREATED)),
//gridSpare.Column("DATECREATED", "Spare Requisition Date"),
webGrid.Column(header: "SRS Generation Status", format: @<text>@Html.Label(item.objSpareRequisition.ISSRSGENERATE == 1 ? "SRS Generated" : "SRS Generation Pending")</text>),
//gridSpare.Column("City", "City"),
webGrid.Column(format: (item) =>
{
WebGrid childGrid = new WebGrid(source: item.objSpareRequisitionDetail, canSort: false, canPage: false);
return childGrid.GetHtml(
htmlAttributes: new { @class = "ChildGrid" },
columns: childGrid.Columns(
childGrid.Column("SPAREREQUISITIONID", "Spare Requisition ID"),
childGrid.Column("ITEMNAME", "Part Description"),
childGrid.Column("QUANTITY", "Quantity"),
childGrid.Column(header: "Part Required", format: @<text>@Html.Label(item.objSpareRequisitionDetail.NOTREQUIRED == 1 ? "Not Required" : "Required")</text>),
childGrid.Column(header: "Is Chargeable", format: @<text>@Html.Label(item.objSpareRequisitionDetail.ISCHARGABLE == 1 ? "Yes" : "No")</text>),
childGrid.Column(header: "Is Used From Kit", format: @<text>@Html.Label(item..ISUSEDFROMKIT == 1 ? "Yes" : "No")</text>)
));
})
))