使用 onSelectionChange 时我做错了什么 [英] What am I doing wrong when using onSelectionChange

查看:19
本文介绍了使用 onSelectionChange 时我做错了什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发者身上发现了这个触发器onSelectionChange(e).google.com 如果选择了单个空单元格,它应该将背景设置为红色.我只是复制和粘贴没有得到那个结果.我认为我没有遗漏任何一步,我们将不胜感激.

I found this trigger onSelectionChange(e) on developers.google.com it should set background to red if a single empty cell is selected. I'm not getting that result with just copy and paste. I don't think I'm missing a step any help would be appreciated.

/**
 * The event handler triggered when the selection changes in the spreadsheet.
 * @param {Event} e The onSelectionChange event.
 */
function onSelectionChange(e) {
  // Set background to red if a single empty cell is selected.
  var range = e.range;
  if(range.getNumRows() === 1 
      && range.getNumColumns() === 1 
      && range.getCell(1, 1).getValue() === "") {
    range.setBackground("red");
  }
}

推荐答案

更新:

它似乎已全面向所有用户推出.您应该能够在不修改代码的情况下使其工作.e 事件对象类似于 onEdit 事件对象.

It seems it is fully rolled out to all users. You should be able to get it working without any modification to the code. The e, event object is similar to the onEdit event object.

onSelectionChange 是最近推出的功能.考虑等待几天将该功能推出到您的特定项目和电子表格.

onSelectionChange is a recently rolled out feature. Consider waiting a few days for the feature to be rolled out to your specific project and spreadsheet.

这篇关于使用 onSelectionChange 时我做错了什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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