繁体   English   中英

AG-Grid 按钮不导航到页面

[英]AG-Grid Button Does Not Navigate to the Page

在我的应用程序中,我使用 AG-Grid 来显示列表。 此列表的其中一列是详细信息列。 在其中,有一个按钮可以导航到该行的详细信息。 但是当我单击按钮并且无法导航到该行的详细信息时,出现以下错误。 我的代码如下,我应该怎么做才能使按钮工作? 在此处输入图像描述

列出 TS:

constructor(
    private _router: Router,
  ) {}
  getTicketList() {
    // this.rowData = this._adminService.getTicketList(this.Filter);

    this._adminService
      .getTicketList(this.Filter)
      .subscribe((response: any) => {
        this.rowData = response;
      });
  }

  rowData: Observable<ITicket[]>;
        {
          headerName: 'Detay', field: 'TicketId', cellRenderer: BtnCellRenderer,
          cellRendererParams: {
            clicked: function (field: any) {
              this._router.navigateByUrl("/admin/ticket-detail/" + this.data.TicketId);
            }
          },
        },

BtnCellRenderer TS:

@Component({
    selector: "btn-cell-renderer",
    template: `<button mat-icon-button matTooltip="Detay" (click)="btnClickedHandler($event)">
  <mat-icon> open_in_browser</mat-icon>
  </button>`
})
export class BtnCellRenderer implements ICellRendererAngularComp, OnDestroy {

    refresh(params: ICellRendererParams): boolean {
        throw new Error("Method not implemented.");
    }
    private params: any;

    agInit(params: any): void {
        this.params = params;
    }

    btnClickedHandler() {
        this.params.clicked(this.params.value);
    }
}

你能试一下吗


clicked: function (field: any) {
  this._router.navigateByUrl("/admin/ticket-detail/" + this.data.TicketId);
}.bind(this)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM