在onEdit中解释`e`事件参数的用途 [英] Explain purpose of `e` event parameter in onEdit

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

问题描述

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

 函数my_on_edit(e){
var s = findSheetById_(EXAMPLEridId) ;
var r = e.range;
s.getRange(r.rowStart,r.columnEnd + 1).setValue(s.getName());


函数findSheetById_(id){
var sheets = SpreadsheetApp.getActive()。getSheets();
for(var i in sheets)
if(sheets [i] .getSheetId()== id)
return sheets [i];
throw'无法找到带有ID的表单:'+ id;


解决方案

函数 my_on_edit 可能会绑定onEdit触发器,请查看 Google脚本触发器一>。活动触发器的列表可在脚本编辑器的 Resources 菜单中找到。

在电子表格上的每个编辑操作中,通过传递编辑事件对象来调用此处理函数。 e 包含字段:

  {
字符串用户,
SpreadSheet源,
范围范围,
对象值
}

您可以在电子表格编辑活动部分找到更详细的描述


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`事件参数的用途的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆