Navigate to other pages google apps script UiApp

2019-05-31 11:17发布

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

2条回答
该账号已被封号
2楼-- · 2019-05-31 11:29

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;
}
查看更多
女痞
3楼-- · 2019-05-31 11:34

One way is to have different panels representing different pages. Initially hide all but the first page and then unhide subsequent pages

查看更多
登录 后发表回答