1

In google sheets, when we click on Format->Conditional Formatting, a sidebar opens. Now click on Format->Alternating colors, another sidebar opens and it actually is on top of the earlier sidebar. when we close the "Alternating colors" sidebar, the "Conditional format rules" sidebar is still there.

From apps script, when we open a sidebar using SpreadsheetApp.getUi().showSidebar() and then try to open a second sidebar, the first sidebar is closed.

How can I replicate the behavior as seen in google sheets? i.e when I create 2 sidebar's both should exist unless I explicitly close it.

Rubén
  • 34,714
  • 9
  • 70
  • 166
Putta
  • 67
  • 7

4 Answers4

0

Sidebars do not suspend the server-side script while the dialog is open.

It says from the documentation that:

Client-side calls to server-side functions are asynchronous: after the browser requests that the server run the function doSomething(), the browser continues immediately to the next line of code without waiting for a response.

This means that server function calls may not execute in the order you expect. If you make two function calls at the same time, there is no way to know which function will run first; the result may differ each time you load the page.

In this situation, success handlers and failure handlers help control the flow of your code.

Jessica Rodriguez
  • 2,899
  • 1
  • 12
  • 27
  • I am not sure I get what you are trying to say here... I understand about success handlers and failure handlers. But, I don;t think it's relevant to what I am trying to do here.. The two sidebars that I am trying to open is invoke from 2 separate menu items. i.e 2 calls to SpreadsheetApp.getUi().showSidebar(). I just want to replicate the behavior that exists in google sheets – Putta Nov 01 '18 at 09:55
  • It means when you open another sidebar, the other one will automatically close because the functions are asynchronous. – Jessica Rodriguez Nov 02 '18 at 01:50
  • But, since this can be done on google sheets, I was of the opinion that we can do it through apps script as well. No? – Putta Nov 02 '18 at 04:49
  • Yes this can possibly done with the UI in google sheets. So the other option for handling the closing behavior of the side bar in your code is to use success handler and failure handler. – Jessica Rodriguez Nov 02 '18 at 06:31
0

On G Suite Document Editors, sidebars, modal and modal less built-in dialogs can't overlap other user interface element of the same type.

It's possible to have a sidebar and a dialog, modal or modal less both not two sidebars but it's possible to use HTML and CSS to play with div tags to move them around their container and even to create popups and alerts.

Rubén
  • 34,714
  • 9
  • 70
  • 166
0

Perhaps the answer is to ask Google if multiple sidebars can be made the default. There needs to be a reason. Mine is that, given that a TBA interface can "work" Google sheets from JSON records, it will also be able to "work" all different types of multimedia (like 3D animation), if there were sidebars to properly accommodate them. Moreover, because JSON records can be individually stored at sites like myjson.com, multiple records can be combined and controlled by TBA to support collaborative work.

Chris Glasier
  • 791
  • 2
  • 10
  • 21
0

The solution can be simulated all with the use of CSS and HTML. I created a sidebar with animated (CSS) tags in the HTML to show or hide different menus. It's all one html page, but you can hide or show different areas with CSS animation.

James VB
  • 93
  • 7