sobota 28. března 2015

Create user DialogBox

How to create user dialogBox in Spreadsheet.

Example 1

old version of Spreadsheet.
function showURLDialogBox(){
  var app = UiApp.createApplication().setHeight(40).setWidth(200);
  app.setTitle("The best URL");
  var link1 = app.createAnchor('office.lasakovi.com', 'http://office.lasakovi.com/');
   // add widgets to panels
  app.add(app.createVerticalPanel().add(link1)); 
  var doc = SpreadsheetApp.getActive();
  doc.show(app);
}

 








Example 2

function showURLDialogBox2(){
  var app = UiApp.createApplication().setHeight(60).setWidth(200);
  app.setTitle("The best URL");
  var link1 = app.createAnchor('office.lasakovi.com', 'http://office.lasakovi.com/');
  var link2 = app.createAnchor('HowToExcel', 'http://JakNaExcel.cz/');

  app.add(app.createVerticalPanel().add(link1).add(link2));
  var doc = SpreadsheetApp.getActive();
  doc.show(app);






 

Example 3

new version

function showPrompt() {
  // New version
  var ui = SpreadsheetApp.getUi();

  var result = ui.prompt(
      'Please enter your name:',
      ui.ButtonSet.OK_CANCEL);

  var button = result.getSelectedButton();
  var text = result.getResponseText();

  if (button == ui.Button.OK) {
    // if clicked "OK".
    ui.alert('Your name is ' + text + '.');
  } else if (button == ui.Button.CANCEL) {
    // if is clicked "Cancel".
    ui.alert('I didn\'t get your name.');
  } else if (button == ui.Button.CLOSE) {
    // if is X in the title bar.
    ui.alert('You closed the dialog.');
  }
}

 

Žádné komentáře:

Okomentovat