使用onSelectionChange时我在做什么错 [英] What am I doing wrong when using 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屋!