How to Load a UI from Another UI (Redirection)

2019-09-08 02:30发布

问题:

I may be thinking about this the wrong way... but I have 2 different UIs built using UiApp;

Part 1: the "Project Index UI" which holds a list of all approved/pending projects.

  • I have unique IDs for each project, with a row of information in another Spreadsheet that correlates to each ID.

Example: Project ID 20857 really points to row 4 in "Project Spreadsheet".

Part 2: the "Project Details UI" which is essentially an interface for editing the values in the Spreadsheet and updating calendar events with the new information.


The goal is to give my boss an index of all projects that are currently in the system. Then, as he wants, he can click on a project ID to load another UI that presents the information for that ID.

So: I was thinking about having the Project Name as an anchor, where the ID is embedded such as:

var anchor = app.createAnchor("Some Project", "https://sites.google.com/site/mySite/asdf&ID=20857");

Where asdf is the page where the "Project Details UI" is located. Then I would parse the URL to get the ID, and load the information into the Project Details UI that way.


What I'm thinking is that this is way too complicated, and that there is an easier way to accomplish this but I'm just not sure.

Is there a better method for generating a new UI with specific data obtained through a "link" of some sort in the original UI?

Solution: TabPanel with 2 tabs - each ID acts as a reference to a row of information in a Spreadsheet. When a button is clicked, a serverHandler invokes a function with that ID as a parameter, which fills the second tab with information for that ID.

Below are two illustrations of the UIs and how they should function:

回答1:

If you have them written already and dont want to change much, it will work ok but it might be a bit slow, as each link click opens a new tab which loads the site and 2nd apps script which can be slow. If you want something faster and a more streamlined interface you should change your code so you can load the 2nd gui inside the 1st one, for example use a stackpanel or a list that expands when you click it and put inside the 2nd ui. For this you need to merge both projects sources.