AG Grid / Angular 6 - 尝试使用两列渲染超链接
创始人
2024-09-30 00:00:19
0

在AG Grid和Angular 6中,我们可以使用自定义单元格渲染器来呈现超链接。以下是一个使用两个列渲染超链接的示例解决方法:

  1. 首先,创建一个名为"LinkCellRendererComponent"的自定义单元格渲染器组件:
import { Component } from '@angular/core';

@Component({
  selector: 'app-link-cell-renderer',
  template: `
    
      {{ params.data.name1 }}
      {{ params.data.name2 }}
    
  `,
})
export class LinkCellRendererComponent {
  params: any;

  agInit(params: any): void {
    this.params = params;
  }
}
  1. 在你的组件中,使用上述自定义单元格渲染器组件来呈现超链接列:
import { Component } from '@angular/core';
import { LinkCellRendererComponent } from './link-cell-renderer.component';

@Component({
  selector: 'app-grid',
  template: `
    
    
  `,
})
export class GridComponent {
  rowData = [
    { name1: 'Link 1', link1: 'https://link1.com', name2: 'Link 2', link2: 'https://link2.com' },
    // 添加更多行...
  ];

  columnDefs = [
    { headerName: 'Links', field: 'links', cellRendererFramework: LinkCellRendererComponent },
    // 添加更多列...
  ];
}
  1. 最后,在你的模块中声明和导入相关组件:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AgGridModule } from 'ag-grid-angular';
import { GridComponent } from './grid.component';
import { LinkCellRendererComponent } from './link-cell-renderer.component';

@NgModule({
  imports:      [ BrowserModule, AgGridModule.withComponents([LinkCellRendererComponent]) ],
  declarations: [ GridComponent, LinkCellRendererComponent ],
  bootstrap:    [ GridComponent ]
})
export class AppModule { }

这样,你就可以在AG Grid中使用"LinkCellRendererComponent"来渲染两列超链接了。

相关内容

热门资讯

事发当天!上饶辅助设备出租,真... 事发当天!上饶辅助设备出租,真是是真的辅助工具(有挂头条)-哔哩哔哩上饶辅助设备出租脚本下载中分为三...
随着!菠萝神辅助器app,一直... 随着!菠萝神辅助器app,一直是有辅助平台(有挂教程)-哔哩哔哩1、很好的工具软件,可以解锁游戏的菠...
推出新举措!兴动海满辅助,一贯... 您好,兴动海满辅助这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在...
做出回应!微乐贵阳捉鸡麻将挂软... 做出回应!微乐贵阳捉鸡麻将挂软件,果然真的是有辅助神器(有挂秘诀)-哔哩哔哩1、打开软件启动之后找到...
反观!九游破解辅助插件,都是真... 反观!九游破解辅助插件,都是真的有辅助神器(有挂秘籍)-哔哩哔哩九游破解辅助插件能透视中分为三种模型...
据文件显示!科米台州麻将辅助,... 据文件显示!科米台州麻将辅助,真是有挂辅助app(竟然有挂)-哔哩哔哩1、每一步都需要思考,不同水平...
今天上午!赣湘互娱挂,总是是有... 今天上午!赣湘互娱挂,总是是有辅助修改器(有挂详情)-哔哩哔哩1、在赣湘互娱挂插件功能辅助器技巧中,...
来临!广西友乐解码器辅助器,原... 来临!广西友乐解码器辅助器,原来真的是有辅助脚本(真的有挂)-哔哩哔哩1.广西友乐解码器辅助器 选牌...
来临!新天道辅助脚本,确实有挂... 来临!新天道辅助脚本,确实有挂辅助下载(有挂秘诀)-哔哩哔哩1、金币登录送、破产送、升级送、活动送。...
近期!青橙竞技卡五星辅助,好像... 近期!青橙竞技卡五星辅助,好像真的是有辅助脚本(竟然有挂)-哔哩哔哩1、用户打开应用后不用登录就可以...