当双击ag-grid单元格粘贴(ctrl + V)一些数据时, 我想要该事件(粘贴),但无法获取单元格的事件
我尝试了该特定单元格的 onProcessCellFromClipboard ,但这也没有触发
columnDefs: [
{
field: 'name',
headerName: 'name',
width: 175,
includeInSearch: true,
suppressSorting: true,
suppressFilter: true,
suppressMenu: true,
onProcessCellFromClipboard : (params) = > {
//expecting this event to be fired when we do ctrl+v but not working
}
}
]
最佳答案
在 Angular 中,您可以使用所有预定义的 JavaScript 事件来处理用户输入
这里有两个函数一直解决了我的生活:oninput 和 onchange
如果您想在 Angular 中使用它们,您可以将其添加到模板中:
<component (input)='youFunction()' (change)='yourSecondFunction()'></component>
对于您使用 AG-Grid 时的情况,有几个针对列或单元格的自定义事件:
例如,对于单元格编辑:可以覆盖 cellValueChanged
、cellEditingeStarted 和 cellEditingStopped 函数,例如:
在您的columnDef中添加以下内容:
onCellValueChanged : this.YourOnCellValueChanged ,
onCellEditingStarted: this.thePasteStart,
onCellEditingStopped: this.thePasteEnd,
并在您的脚本中添加对该函数的引用
function YourOnCellValueChanged (params) {
console.log('The column has been changed '+ params);
}
function thePasteStart(event){
console.log("Paste started "+ event.value)
}
function thePasteEnd(event){
console.log("Paste Ended "+ event.value)
}
关于javascript - 双击时是否有网格单元格(粘贴)事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58484822/