我使用的是带有角8和企业许可证的ag网格。由于某些原因,默认的“复制”、“带有标题的复制”上下文菜单项不可用。只有“出口”项目出现了。其他企业功能运行良好,但我似乎不知道如何启用“复制”。
我不确定我下一步能尝试什么,我试过使用不同的导入,禁用功能,.
方格角标签:
<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角网格HTML时,一些功能停止工作(比如侧栏),并得到浏览器错误:
ag-Grid:无法使用列工具面板作为模块@ag-网格-企业/列-工具面板不存在。您需要用: import“@ag-格栅-企业/列-工具面板”加载该模块。
发布于 2020-01-21 09:11:29
是的,所以很明显我用错了这个包来做方格角组件。
在我使用的模块文件中:
从‘ag-网格-角’导入{ AgGridModule };
切换到下面的包,整个过程就像黄油一样流畅:
从“@ag-网格-社区/角”导入{ AgGridModule };
发布于 2020-02-04 19:35:27
此外,您的package.json可能有问题。我最近升级了Ag版本,控制面板停止工作。只有在升级了node_modules中的所有@转角/*包和删除/重新创建@ag-网格包文件夹之后,错误才消失。
以下是我的package.json:https://stackblitz.com/edit/ag-grid-angular-hello-world-mnmfpr?file=package.json的链接
发布于 2020-03-16 12:46:32
只是想让那些面临Ag-Grid-React类似问题的人(我的剪贴板上下文菜单将拒绝识别和显示带有标头选项的复制和复制),在这个线程上执行与接受的答案相同的操作,即:
而不是使用
import {AgGridReact} from 'ag-grid-react';
import 'ag-grid-enterprise';使用下面的
import {AgGridReact} from "@ag-grid-community/react";
import {AllModules} from "@ag-grid-enterprise/all-modules";在这里可以找到正确用法的示例:https://www.ag-grid.com/javascript-grid-clipboard/
如果您使用的是“从‘ag-grid-react’导入{ AgGridReact }”,则需要将@ag-grid-community/ are和@ag-grid-enterprise/all-模块安装为单独的NPM包;
https://stackoverflow.com/questions/59837146
复制相似问题