开发者

pass argument to mouseCallback

I have a simple, but problematic question.

Is there a way, using google script to send an argument to a mouseCallback? Some examples are explained here, but each time the cell in written in the function.

I want this cell to change over time, and I need to pass a string to the callback.

This works

function foo() {
  var doc = SpreadsheetApp.getActiveSpreadsheet();
  var app = UiApp.createApplication();

  var button = app.createButton('submit');
  app.add(button);

  var handler = app.createServerClickHandler('b');
  button.addClickHandler(handler);

  doc.show(app);
}

function b() {
  var doc = SpreadsheetApp.getActiveSpreadsheet();
  var cell = doc.getRange('a1');
  cell.setValue(Number(cell.getValue()) + 开发者_如何学Python1);

  var app = UiApp.getActiveApplication();
  app.close();
  // The following line is REQUIRED for the widget to actually close.
  return app;
}

I would like something like this

function foo() {
  var doc = SpreadsheetApp.getActiveSpreadsheet();
  var app = UiApp.createApplication();

  var button = app.createButton('submit');
  app.add(button);

  var value = 'A1';
  var handler = app.createServerClickHandler('b', value);
  button.addClickHandler(handler);

  doc.show(app);
}

function b(value) {
  var doc = SpreadsheetApp.getActiveSpreadsheet();
  var cell = doc.getRange(value);
  cell.setValue(Number(cell.getValue()) + 1);

  var app = UiApp.getActiveApplication();
  app.close();
  // The following line is REQUIRED for the widget to actually close.
  return app;
}

Can anyone help me in this?

Thanks !


There is answers to this question in here :

Thansk to google forum users :)

http://www.google.com/support/forum/p/apps-script/thread?fid=2ef3693fc9aee1050004ad903de88dd4&hl=en

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜