我试图仅根据名为isPrimary的值显示此删除按钮。如果isPrimary是真的,则不要显示它。
问题是如何根据模型中的值有条件地显示最后一个?
以下是我目前的代码。
@(Html.Kendo().Grid(Model.GiIncidentReportList)
.Name("IRGrid")
.Columns(columns =>
{
columns.Bound(r => r.IncidentReport.IR_IncidentID)
.Template(@<text>@Html.Raw(@Html.ActionLink("[replacetext]", "Index", "ApprovalWorkflow",
new { area = "Dailylog", id = item.IncidentReport.IR_IncidentID, createdBy = item.IncidentReport.IR_CreatedByLoginID, isPrimaryReport = isPrimary }, null).ToHtmlString().Replace("[replacetext]", "<img src=\"/Images/icon_edit.gif\" />")) </text>)
.Title("").Width(70);
columns.Bound(r => r.IncidentReport.IR_CaseNumber).Title("Case Number");
columns.Bound(r => r.IncidentCreatedByName).Title("Created By");
columns.Bound(r => r.IncidentCreatedDateTime).Title("Created Date");
columns.Bound(r => r.IncidentUpdatedByName).Title("Updated By");
columns.Bound(r => r.IncidentUpdatedDateTime).Title("Updated Date");
columns.Template(p => @Html.ActionLink("Delete","DeleteIncidentReport","IncidentReport",
new { incidentReportId = p.IncidentReport.IR_IncidentID, dlLogId = p.IncidentReport.DL_LogID, incidentType = p.IncidentReport.IT_IncidentType },
new { @class = "k-button k-button-icontext", onclick = "return confirm('Are you sure you wish to delete this report?')" }).ToHtmlString()
);
}
)
)
答案 0 :(得分:0)
请尝试使用以下代码段。
columns.Template(p => @Html.ActionLink("Delete","DeleteIncidentReport","IncidentReport",
new { incidentReportId = p.IncidentReport.IR_IncidentID, dlLogId = p.IncidentReport.DL_LogID, incidentType = p.IncidentReport.IT_IncidentType },
new { @class = "k-button k-button-icontext", onclick = "return confirm('Are you sure you wish to delete this report?')" }).ToHtmlString()
).Visible(isPrimary == false);