const columnDefs = [ { field: 'athlete', draggable: true }, { field: 'age' }, { field: 'country' }, { field: 'year' }, { field: 'sport' }, { field: 'gold' }, { field: 'silver' }, { field: 'bronze' } ];
onRowDragEnd(event) { const data = event.node.data; const targetGridId = 'myOtherGrid'; // change this to the ID of the target grid const targetGridApi = this.gridApi.getGridById(targetGridId); targetGridApi.applyTransaction({ add: [data] }); }
onApplyTransaction(event) { const rowsToAdd = event.add; this.rowData = this.rowData.concat(rowsToAdd); }
注意:在Ag-grid中,我们可以使用Vue.js,Angular和React等框架来实现drag and drop row到另一个grid的解决方案。