Ag-grid角度复制菜单选项不可用 [英] Ag-grid angular copy menu option not available

查看:66
本文介绍了Ag-grid角度复制菜单选项不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有企业许可证的,角度为8的ag-grid. 由于某些原因,默认的复制",带标题复制"上下文菜单项不可用.仅显示导出"项.其他企业功能运行正常,但我似乎无法弄清楚如何启用复制".

I am using ag-grid with angular 8 with an enterprise license. For some reason, the default "copy", "copy with headers" context menu items are not available. Only the "Export" item is showing up. Other enterprise features are working fine, but I can't seem to figure out how to enable "copy".

我不确定下一步该怎么做,我尝试使用其他导入功能,禁用功能等...

I'm not sure what I can try next, I've tried using different imports, disabling features, ...

ag-grid-angular标签:

The ag-grid-angular tag:

<ag-grid-angular
      #agGrid
      style="width: 800px; height: 500px;"
      class="ag-theme-balham"
      [columnDefs]="columnDefs"
      [defaultColDef]="defaultColDef"
      rowGroupPanelShow="always"
      [modules]="modules"
      [sideBar]="true"
      rowSelection="multiple"
      enableRangeSelection="true"
      setSuppressClipboardPaste="false"
      [suppressDragLeaveHidesColumns]="true"
      [suppressMakeColumnVisibleAfterUnGroup]="true"
      [rowData]="rowData"
      (gridReady)="onGridReady($event)"

    ></ag-grid-angular>

测试组件文件如下:

import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { AllModules , Module} from "@ag-grid-enterprise/all-modules";
import "@ag-grid-enterprise/core";
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent  {

  private gridApi ;
  private gridColumnApi ;

  private columnDefs;
  private defaultColDef;
  private rowData;
  public modules: Module[] = AllModules;
  constructor(private http: HttpClient) {

    this.columnDefs = [
      {
        field: "athlete",
        width: 150,
        filter: "agTextColumnFilter"
      },
      {
        field: "age",
        width: 90
      },
      {
        field: "country",
        width: 120
      },
      {
        field: "year",
        width: 90
      },
      {
        field: "date",
        width: 110
      },
      {
        field: "gold",
        width: 100
      },
      {
        field: "silver",
        width: 100
      },
      {
        field: "bronze",
        width: 100
      },
      {
        field: "total",
        width: 100
      }
    ];
    this.defaultColDef = {
      enableValue: true,
      enableRowGroup: true,
      enablePivot: true,
      sortable: true,
      filter: true,
    };
  }


  onGridReady(params) {
    this.gridApi = params.api;
    this.gridApi.setSuppressClipboardPaste = false;
    this.gridColumnApi = params.columnApi;

    this.http
      .get("https://raw.githubusercontent.com/ag-grid/ag-grid/master/packages/ag-grid-docs/src/olympicWinners.json")
      .subscribe(data => {
        this.rowData = data;
      });
  }

}

我不确定以下内容是否相关,但是我将其添加为额外信息:当我尝试将企业模块"AllModules"绑定到ag-angular-grid HTML时,某些功能停止工作(例如边栏),然后出现浏览器错误:

I'm not sure if the following is related, but I'll add it as extra info: when I try to bind the enterprise modules "AllModules" to the ag-angular-grid HTML, some features stop working (like the sidebar) and I get the browser error:

ag-Grid:无法将列工具面板"用作模块 @ ag-grid-enterprise/column-tool-panel不存在.您需要加载 带有以下模块的模块:导入"@ ag-grid-enterprise/column-tool-panel"

ag-Grid: unable to use Column Tool Panel as module @ag-grid-enterprise/column-tool-panel is not present. You need to load the module with: import "@ag-grid-enterprise/column-tool-panel"

推荐答案

正确,因此显然我对ag-grid-angular组件使用了错误的包.

Right, so apparently I've been using the wrong package for the ag-grid-angular component.

在我的模块文件中,我正在使用:

In my module file I was using:

从"ag-grid-angular"导入{AgGridModule};

import { AgGridModule } from 'ag-grid-angular';

切换到以下软件包可以使整个过程像黄油一样平稳:

switching to the following package made the whole thing work smooth as butter:

从'@ ag-grid-community/angular'导入{AgGridModule};

import { AgGridModule } from '@ag-grid-community/angular';

这篇关于Ag-grid角度复制菜单选项不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆