【问题标题】:Conditionally show columns.template in kendo ui grid有条件地在剑道 ui 网格中显示 columns.template
【发布时间】:2014-09-08 13:38:34
【问题描述】:

我试图仅根据名为 isPrimary 的值显示此删除按钮。如果 isPrimary 为 true,则不显示它。

问题是如何根据模型中的值有条件地显示最后一个?

这是我目前拥有的代码。

 @(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()

                          );
                  }
                  )
            )

【问题讨论】:

    标签: kendo-ui grid telerik


    【解决方案1】:

    请尝试以下代码 sn-p。

    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);
    

    【讨论】:

    • 这已经足够让我思考解决方案了。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2015-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多