I’m implementing a treeView for the first time in Google Apps Script and running into some trouble.
This handler does get fired ok when selecting a treeItem
tree.addSelectionHandler(app.createServerSelectionHandler("restClick"));
I was expecting to be able to identify the selected item in the handler
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;
}
The above code identifies the tree object correctly – however I can’t figure out how to get the selectedItem – there is no appropriate method such as getSelectedItem() and there is no useful property of (e) that helps either
Thank you.
This is a known issue. You should follow the link and star this issue to keep track of updates and kind of vote for it. On the issue comments there’s an explanation for a somewhat cumbersome workaround, if this is really important to you.
The “tree object” should work like all others widgets on Apps Script, having a
setNamemethod where we could get on the handler event parameters item name or index (after adding the tree as a callback element in the handler using theaddCallbackElement) e.g.But this does not work, as informed in the bug report.