2
我在Google Apps腳本中首次實現了treeView,並且遇到了一些麻煩。確定在Google Apps腳本樹中選擇了哪個TreeItem
選擇treeItem
tree.addSelectionHandler(app.createServerSelectionHandler("restClick"));
我期待能夠識別在處理程序
function restClick(e) {
var app = UiApp.getActiveApplication();
Logger.log(e.parameter.source);
var tree = app.getElementById(e.parameter.source);
Logger.log(tree.getId());
return app;
}
上面的代碼所選擇的項目時,該處理程序被解僱確定正確地識別樹對象 - 但我不知道如何獲得selectedItem - 沒有適當的方法,如getSelectedItem(),沒有有用的屬性(e),可以幫助
謝謝。
Henrique,感謝您的快速評論。但是,樹對象奇怪地沒有setName()方法 - https://developers.google.com/apps-script/class_tree。 – bruce
你說得對,沒有'setName'方法。然後再搜索一下,我發現無法得到像這樣的選定項目。我已經更新了我的答案。 –
恩裏克,謝謝你指點我那個錯誤報告。我看了一下解決方法,但我不認爲這種方法適用於我。我會等待,直到它被修復。再次感謝你。 Bruce – bruce