How do customize a popup like Snackbar or Notification dialog with a message?

ε祈祈猫儿з 提交于 2019-12-24 19:13:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!