【问题标题】:Is there an event for agrid cell (paste) when double clicked双击时是否有 agrid 单元格(粘贴)事件
【发布时间】:2023-03-28 06:29:01
【问题描述】:

当一个 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
      }
    }
  ]

【问题讨论】:

    标签: javascript ag-grid ag-grid-angular


    【解决方案1】:

    在 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)
    
    }
    

    【讨论】:

    • 谢谢你,但我想捕捉 Ctrl + v 剪贴板事件,我现在无法使用任何 ag-grid 事件。
    • 我认为没有其他东西可以使用 ag-grid 触发它
    猜你喜欢
    • 1970-01-01
    • 2018-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-06
    • 1970-01-01
    • 2021-03-16
    • 1970-01-01
    相关资源
    最近更新 更多