导航到其他页面谷歌应用脚​​本UiApp [英] Navigate to other pages google apps script UiApp

查看:101
本文介绍了导航到其他页面谷歌应用脚​​本UiApp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以向我解释如何在Google Apps脚本中导航到新页面吗?我最初的想法是隐藏或删除应用程序内的所有子元素,然后相应地重建它。这是正确的做法吗?



提前致谢

解决方案

已经到达了页面导航/组织的一种非常常见的方法。

这是另一种使用查询字符串属性分离到不同UI路径的方法。这有额外的好处,让活动微调。



你可以在下面的链接中看到它的动作,代码在它下面给它启动。希望这提供了另一个角度。



https: //script.google.com/macros/s/AKfycbx68wR5HmCbil_LY8LlMd2m16_xNEdEtXq7-YfgqsMPqeoe-E3L/exec

 函数doGet( e){
var app = UiApp.createApplication();
var page = e.parameter.page

//添加一个默认页面
if(!page){
page ='1';
}

if(page ==='1'){
var label = app.createLabel('您位于第1页'。)

var anchor = app.createAnchor(Next page,ScriptApp.getService()。getUrl()+?page = 2);
anchor.setTarget('_ self');

app.add(label);
app.add(anchor);

else if(page ==='2'){
var label = app.createLabel('现在你在第2页')

var anchor = app.createAnchor(Go back,ScriptApp.getService()。getUrl()+?page = 1);
anchor.setTarget('_ self');

app.add(label);
app.add(anchor);
}

返回应用;
}


Can someone explain to me how to go about navigating to a new page in google apps script is done ? My initial thought is to hide or delete all child elements within the app and then rebuild it accordingly. Is this the right approach ?

thanks in advance

解决方案

Srik already arrived one very common approach for page navigation/organization.

Here is another way using a query string attribute to fork off to a different UI path. This has the added benefit of getting the activity "spinner".

You can see it in action at this link below with the code powering it underneath it. Hope this provides another perspective.

https://script.google.com/macros/s/AKfycbx68wR5HmCbil_LY8LlMd2m16_xNEdEtXq7-YfgqsMPqeoe-E3L/exec

function doGet(e) {
  var app = UiApp.createApplication();
  var page = e.parameter.page

  //add a default page
  if(!page){
    page = '1';  
  }

  if(page === '1'){
    var label = app.createLabel('You are in page 1.')

    var anchor = app.createAnchor("Next page",ScriptApp.getService().getUrl()+"?page=2");
    anchor.setTarget('_self');

    app.add(label);
    app.add(anchor);
  }
  else if(page === '2'){
    var label = app.createLabel('You are in page 2, now.')

    var anchor = app.createAnchor("Go back",ScriptApp.getService().getUrl()+"?page=1");
    anchor.setTarget('_self');

    app.add(label);
    app.add(anchor);
  }

  return app;
}

这篇关于导航到其他页面谷歌应用脚​​本UiApp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆