【问题标题】:Angular Kendo UI show Grid items as hyperlinkAngular Kendo UI 将网格项目显示为超链接
【发布时间】:2018-09-05 20:33:28
【问题描述】:

我是 Angular Kendo UI 的新手,我正在使用 website 上的 Kendo UI Grid System。

我的网格数据有如下名称、日期和链接的报告:

gridData: IReport[] = [
    {
      "date": "9/5/2018",
      "reportName": "Report 1",
      "reportLink": "http://google.com/",
      "reportStatus": "Success"
    },
    {
      "date": "9/7/2018",
      "reportName": "Report 2",
      "reportLink": "http://yahoo.com/",
      "reportStatus": "Success"
    },
    {
      "date": "8/5/2018",
      "reportName": "Report 3",
      "reportLink": "http://msn.com/",
      "reportStatus": "Success"
    },]

我想用 reportLink 作为超链接在 UI 上显示这个网格。这就是我的 html 的外观:

<kendo-grid  [resizable]="true" [data]="gridData" [height]="500">
  <kendo-grid-column field="date" title="Date"  width="40">
  </kendo-grid-column>
  <kendo-grid-column field="reportName" title="Report Name" width="50">
  </kendo-grid-column>
  <kendo-grid-column field="reportLink" title="Report Link" width="50"> 
      <ng-template kendoGridCellTemplate let-dataItem *ngFor="let data of gridData">
            <a href="{{data.reportLink}}">{{data.reportLink}}</a>
      </ng-template>
  </kendo-grid-column>
  <kendo-grid-column field="reportStatus" title="Report Status" width="80">
  </kendo-grid-column>
</kendo-grid>

我显示了我在 gridData 中循环的链接并将其显示为标签。

  <kendo-grid-column field="reportLink" title="Report Link" width="50"> 
      <ng-template kendoGridCellTemplate let-dataItem *ngFor="let data of gridData">
            <a href="{{data.reportLink}}">{{data.reportLink}}</a>
      </ng-template>
  </kendo-grid-column>

我的问题是报告链接仅显示所有报告的 http:google.com。

我做错了什么?我希望看到 google.com、yahoo.com 和 msn.com 作为我的报告链接。

有什么建议吗?谢谢大家!

【问题讨论】:

    标签: angular kendo-ui kendo-ui-angular2


    【解决方案1】:

    尝试直接绑定到 dataItem。您不需要 *ngFor。

     <kendo-grid-column field="reportLink" title="Report Link" width="50"> 
          <ng-template kendoGridCellTemplate let-dataItem>
                <a [href]="dataItem.reportLink">{{dataItem.reportLink}}</a>
          </ng-template>
      </kendo-grid-column>
    

    【讨论】:

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