我在我的项目中使用 Ag-grid。走了很远之后,我才知道网格用户无法选择的文本。是否有任何帮助我可以从网格中选择和复制文本,或者我需要更改为不同的插件。我无法返回到不同的 UI 插件,也无法购买 Ag-grid。需要为此找出一些代码技巧。我试过下面的 hack 但没有用。
import {Directive, EventEmitter, Output} from '@angular/core';
import {AgGridNg2} from 'ag-grid-angular';
import {GridApi} from 'ag-grid';
@Directive({
selector: '[gridRangeRowSelection]',
})
export class AgGridSelectionDirective {
@Output('gridRangeRowSelection') onChangeEvent = new EventEmitter();
constructor(grid: AgGridNg2) {
grid.rangeSelectionChanged.subscribe(event => {
const api: GridApi = event.api;
// deselect previous rows
this.clearPreviousSelections(api);
const selectedRows = this.getSelectedRows(api);
this.onChangeEvent.emit({rows: selectedRows});
});
}
public getSelectedRows(api: GridApi) {
// get all range selections (ctrl+click/drag for multiple selections)
const rangeSelections = api.getRangeSelections();
const selectedRows = rangeSelections ? …Run Code Online (Sandbox Code Playgroud)