javascript - How to pass data in a button event handler on a Google script extending a spreadheet? -
expand a Google spreadsheet, I run a script showing some data in a sidebar. Below, I want to add a button to match the data.
However, I can not understand how the data handler of the button across this:
- no possibility to have data in the event of a call;
- event is no way to get the button object information, I can only get ID, which is useless if I can not get on UI Instrens manufactured outside handler function).
So what's the trick?
You callback element (possibly a panel which requires you everything wrapping) server handler button You must add before specifying. For example:
function myFunction () {var app = UiApp.createApplication (); Var panel = app.createVerticalPanel (); Add.it ('a'). AddItem ('A') (app.creativebox). AddName ('boxExample')) Add (app.createListBox (). SetName ('listExample'). AddItem ('B')); // ↓↓ This is what you need ↓↓ var handler = app.createServerHandler ('callbackFunction'). AddClallElement (panel); Var btn = app.createButton (BTN, handler); App.add (panel.add (btn)); // show app ...} function callback function (e) {var app = UiApp.getActiveApplication (); App.getElementById ('myPanel'). Add (app.createLabel (e.parameter.boxExample)). Add (app.createLabel (e.parameter ['listExample'])); Return app; }
Comments
Post a Comment