【问题标题】:KendoUI: How to open Kendo grid hyperlink columnKendoUI:如何打开剑道网格超链接栏
【发布时间】:2015-12-08 15:57:38
【问题描述】:

我有一个带有超链接列的 kendoGrid。所需的行为是当我单击该列项目时,它会打开一个新选项卡并打开文档。这个剑道网格有文件列表,点击行将打开文件。我可以通过以下模板打开文档

{ title: "Name", field: "Name", template: kendo.template("<a href='" + constants.serviceUrl + "Document/GetFileContents/#= DocumentId #' onclick='window.open(this.href); return false;'>#= Name #</a>") },

这个模板完美地打开了文档,但是上面模板的问题是当添加一个新文档时它会爆炸,因为那时我没有 DocumentId。

这是我想象的效果,但我觉得我在这个模板中遗漏了一些东西:

 { title: "Name", field: "Name", template: '<a href="\\#" onclick="window.open(this.href); views.titleClick(this)" >#=Name#</a>' },

我已经验证这两个标题都触及了服务层。上面的模板会打开一个新选项卡,但不是打开文档,而是重新加载应用程序。需要帮助! :)

【问题讨论】:

    标签: jquery kendo-ui kendo-grid


    【解决方案1】:

    在用磅符号四处寻找之后,我发现我们可以在 Kendo 网格模板中编写 javascript。所以在传递 DocumentId 之前,我添加了检查它是否未定义。

    下面是工作代码的样子:

      { title: "Name", field: "Name", template: kendo.template("<a href='" + constants.serviceUrl + "Document/GetFileContents/ # if (typeof(DocumentId) === 'undefined'){# -1 #} else {##= DocumentId##}#' onclick='window.open(this.href); return false;'>#= Name #</a>") },
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多