本文介绍了在onEdit中解释`e`事件参数的用途的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题,希望大家能回答我。在以下函数中,我无法理解事件'e'。什么是'e'?我们如何调用函数或函数调用的地方?

  

函数 my_on_edit 可能会绑定onEdit触发器,请查看


I have some question, hope guys can answer me. In this following function, I can't understand event 'e'. What is the 'e'? how we call the function or where's the function called? Give me some example, please!

function my_on_edit(e) {
  var s = findSheetById_(e.gridId);
  var r = e.range;
  s.getRange(r.rowStart, r.columnEnd+1).setValue( s.getName() );
}

function findSheetById_(id) {
  var sheets = SpreadsheetApp.getActive().getSheets();
  for( var i in sheets )
    if( sheets[i].getSheetId() == id )
      return sheets[i];
  throw 'Unable to find sheet with id: '+id;
}
解决方案

Function my_on_edit is probably bound to onEdit trigger, check out Google Script triggers. List of active triggers is available in script editor in Resources menu.

On each edit action on your spreadsheet this handler is called with edit event object passed. e contain fields:

{
    String user,
    SpreadSheet source,
    Range range,
    Object value
}

You can find more detailed description at section "Spreadsheet Edit Events"

这篇关于在onEdit中解释`e`事件参数的用途的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 07:42