0

Is it possible to expand the first element of a tree (GUI) in google apps script? I can't see any methods for that in the API https://developers.google.com/apps-script/class_tree

4

2 回答 2

2

您可以使用TreeItem 方法 setState()打开树的某个树项。

function OpenItem(e)
{
  var app = UiApp.getActiveApplication();
  app.getElementById('Item0').setState(true)
  return app;
}

树项在哪里Item0

工作示例

于 2013-01-30T16:41:28.173 回答
0

这样的事情怎么样?

function treetest(){
var ss=SpreadsheetApp.getActiveSpreadsheet();
var app = UiApp.createApplication()
var tree1 = app.createTree()
var tree2 = app.createTree()
var tree3 = app.createTree()
tree1.add(tree2)
tree1.addItem('item on tree1').addItem('item on tree1').addItem('item on tree1')
tree2.addItem('item on tree2').addItem(tree3).addItem('item on tree2').addItem('item on tree2')
tree3.addItem('item on tree3').addItem('item on tree3')
app.add(tree1)
ss.show(app)
}

在此处输入图像描述

tree2 添加到 tree1 的根,tree3 添加到 tree2 的 2cond 分支

于 2013-01-29T11:33:01.963 回答