问题
I am trying to include a feature in my app that examines the values of a column in a user-uploaded Google sheet and verifies whether they are correct or not. If there are any incorrect values, a popup like Snackbar or Notification dialog will appear listing the incorrect values. If there are no incorrect values, no popup will appear. How do you display a popup with different values depending on the situation? Is there a way to display unique popups directly from the ServerScript without having to create separate pages? Thank you very much!
回答1:
You can do it either by direct interaction with Snackbar's children widgets or by binding them to Custom Properties:
// option 1
app.popups.Snackbar.descendants.SnackbarText.text = message;
// option 2
app.popups.Snackbar.properties.Text = message;
app.popups.Snackbar.visible = true;
You can see first option implementation sample here - https://developers.google.com/appmaker/samples/jdbc/
回答2:
You can create one Snackbar page. In that Page you should have Textbox at the bottom. You can bind that Textbox's value to custom function like getNotificationText();
In the client script right the following code in the common script.
//Client script
var notificationText='';
function setNotificationText(text)
{
notificationText=text;
}
function getNotificationText()
{
return notificationText;
}
Once you do this, you can write following lines from your different methods to display message.
//Client script
setNotificationText('Your message.');
app.popups.Snackbar.visible = true;
来源:https://stackoverflow.com/questions/50882936/how-do-customize-a-popup-like-snackbar-or-notification-dialog-with-a-message